public class TensorflowModel<T extends Output<T>> extends Model<T> implements Closeable
INPUT_NAME
),
and produces a single output tensor (labelled OUTPUT_NAME
).
It accepts an ExampleTransformer
that converts an example's features into a Tensor
, and an
OutputTransformer
that converts a Tensor
into a Prediction
.
The model's serialVersionUID is set to the major Tensorflow version number times 100.
N.B. Tensorflow support is experimental and may change without a major version bump.
Modifier and Type | Field and Description |
---|---|
static String |
INPUT_NAME |
static String |
OUTPUT_NAME |
ALL_OUTPUTS, BIAS_FEATURE, featureIDMap, generatesProbabilities, name, outputIDInfo, provenance, provenanceOutput
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected TensorflowModel<T> |
copy(String newName,
ModelProvenance newProvenance)
Copies a model, replacing it's provenance and name with the supplied values.
|
int |
getBatchSize()
Gets the current testing batch size.
|
Optional<Excuse<T>> |
getExcuse(Example<T> example)
Deep learning models don't do excuses.
|
Map<String,List<com.oracle.labs.mlrg.olcut.util.Pair<String,Double>>> |
getTopFeatures(int n)
Deep learning models don't do feature rankings.
|
protected List<Prediction<T>> |
innerPredict(Iterable<Example<T>> examples)
Called by the base implementations of
Model.predict(Iterable) and Model.predict(Dataset) . |
Prediction<T> |
predict(Example<T> example)
Uses the model to predict the output for a single example.
|
void |
setBatchSize(int batchSize)
Sets a new batch size.
|
copy, generatesProbabilities, getExcuses, getFeatureIDMap, getName, getOutputIDInfo, getProvenance, predict, predict, setName, toString, validate
public static final String INPUT_NAME
public static final String OUTPUT_NAME
public Prediction<T> predict(Example<T> example)
Model
predict does not mutate the example.
Throws IllegalArgumentException
if the example has no features
or no feature overlap with the model.
protected List<Prediction<T>> innerPredict(Iterable<Example<T>> examples)
Model
Model.predict(Iterable)
and Model.predict(Dataset)
.innerPredict
in class Model<T extends Output<T>>
examples
- The examples to predict.public int getBatchSize()
public void setBatchSize(int batchSize)
IllegalArgumentException
if the batch size isn't positive.batchSize
- The batch size to use.public Map<String,List<com.oracle.labs.mlrg.olcut.util.Pair<String,Double>>> getTopFeatures(int n)
This method always returns the empty map.
getTopFeatures
in class Model<T extends Output<T>>
n
- the number of features to return.public Optional<Excuse<T>> getExcuse(Example<T> example)
This method always returns Optional.empty()
.
protected TensorflowModel<T> copy(String newName, ModelProvenance newProvenance)
Model
Used to provide the provenance removal functionality.
public void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.