T
- The output type.public abstract class TensorFlowModel<T extends Output<T>> extends Model<T> implements AutoCloseable
Example
s.
The subclasses are package private and concern themselves with how the model is stored on disk.
N.B. TensorFlow support is experimental and may change without a major version bump.
Modifier and Type | Field and Description |
---|---|
protected int |
batchSize |
protected boolean |
closed |
protected FeatureConverter |
featureConverter |
protected org.tensorflow.Graph |
modelGraph |
protected OutputConverter<T> |
outputConverter |
protected String |
outputName |
protected org.tensorflow.Session |
session |
ALL_OUTPUTS, BIAS_FEATURE, featureIDMap, generatesProbabilities, name, outputIDInfo, provenance, provenanceOutput
Modifier | Constructor and Description |
---|---|
protected |
TensorFlowModel(String name,
ModelProvenance provenance,
ImmutableFeatureMap featureIDMap,
ImmutableOutputInfo<T> outputIDInfo,
org.tensorflow.proto.framework.GraphDef trainedGraphDef,
int batchSize,
String outputName,
FeatureConverter featureConverter,
OutputConverter<T> outputConverter)
Builds a TFModel.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
exportModel(String path)
Exports this model as a
SavedModelBundle , writing to the supplied directory. |
int |
getBatchSize()
Gets the current testing batch size.
|
Optional<Excuse<T>> |
getExcuse(Example<T> example)
Deep learning models don't do excuses.
|
String |
getOutputName()
Gets the name of the output operation.
|
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, copy, generatesProbabilities, getExcuses, getFeatureIDMap, getName, getOutputIDInfo, getProvenance, predict, predict, setName, toString, validate
protected int batchSize
protected final String outputName
protected final FeatureConverter featureConverter
protected final OutputConverter<T extends Output<T>> outputConverter
protected transient org.tensorflow.Graph modelGraph
protected transient org.tensorflow.Session session
protected transient boolean closed
protected TensorFlowModel(String name, ModelProvenance provenance, ImmutableFeatureMap featureIDMap, ImmutableOutputInfo<T> outputIDInfo, org.tensorflow.proto.framework.GraphDef trainedGraphDef, int batchSize, String outputName, FeatureConverter featureConverter, OutputConverter<T> outputConverter)
name
- The model name.provenance
- The model provenance.featureIDMap
- The feature domain.outputIDInfo
- The output domain.trainedGraphDef
- The graph definition.batchSize
- The test time batch size.outputName
- The name of the output operation.featureConverter
- The feature converter.outputConverter
- The output converter.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)
Throws 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()
.
public String getOutputName()
public void exportModel(String path) throws IOException
SavedModelBundle
, writing to the supplied directory.path
- The directory to export to.IOException
- If it failed to write to the directory.public void close()
close
in interface AutoCloseable
Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.