Class TensorflowModel<T extends Output<T>>
java.lang.Object
org.tribuo.Model<T>
org.tribuo.interop.tensorflow.TensorflowModel<T>
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.provenance.Provenancable<ModelProvenance>
,Closeable
,Serializable
,AutoCloseable
This model encapsulates a simple model with a single input tensor (labelled
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.
- See Also:
-
Field Summary
FieldsFields inherited from class org.tribuo.Model
ALL_OUTPUTS, BIAS_FEATURE, featureIDMap, generatesProbabilities, name, outputIDInfo, provenance, provenanceOutput
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected TensorflowModel
<T> copy
(String newName, ModelProvenance newProvenance) Copies a model, replacing it's provenance and name with the supplied values.int
Gets the current testing batch size.Deep learning models don't do excuses.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 ofModel.predict(Iterable)
andModel.predict(Dataset)
.Uses the model to predict the output for a single example.void
setBatchSize
(int batchSize) Sets a new batch size.Methods inherited from class org.tribuo.Model
copy, generatesProbabilities, getExcuses, getFeatureIDMap, getName, getOutputIDInfo, getProvenance, predict, predict, setName, toString, validate
-
Field Details
-
INPUT_NAME
- See Also:
-
OUTPUT_NAME
- See Also:
-
-
Method Details
-
predict
Description copied from class:Model
Uses the model to predict the output for a single example.predict does not mutate the example.
Throws
IllegalArgumentException
if the example has no features or no feature overlap with the model. -
innerPredict
Description copied from class:Model
Called by the base implementations ofModel.predict(Iterable)
andModel.predict(Dataset)
.- Overrides:
innerPredict
in classModel<T extends Output<T>>
- Parameters:
examples
- The examples to predict.- Returns:
- The results of the predictions, in the same order as the examples.
-
getBatchSize
-
setBatchSize
Sets a new batch size. ThrowsIllegalArgumentException
if the batch size isn't positive.- Parameters:
batchSize
- The batch size to use.
-
getTopFeatures
Deep learning models don't do feature rankings. Use an Explainer.This method always returns the empty map.
- Specified by:
getTopFeatures
in classModel<T extends Output<T>>
- Parameters:
n
- the number of features to return.- Returns:
- The empty map.
-
getExcuse
-
copy
Description copied from class:Model
Copies a model, replacing it's provenance and name with the supplied values.Used to provide the provenance removal functionality.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-