Class RegressorConverter
java.lang.Object
org.tribuo.interop.tensorflow.RegressorConverter
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable,com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>,Serializable,OutputConverter<Regressor>,ProtoSerializable<org.tribuo.interop.tensorflow.protos.OutputConverterProto>
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intProtobuf serialization version.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertToBatchOutput(org.tensorflow.Tensor tensor, ImmutableOutputInfo<Regressor> outputIDInfo) Converts aTensorcontaining multiple outputs into a list ofOutputs.convertToBatchPrediction(org.tensorflow.Tensor tensor, ImmutableOutputInfo<Regressor> outputIDInfo, int[] numValidFeatures, List<Example<Regressor>> examples) Converts aTensorcontaining multiple outputs into a list ofPredictions.convertToOutput(org.tensorflow.Tensor tensor, ImmutableOutputInfo<Regressor> outputIDInfo) Converts aTensorinto the specified output type.convertToPrediction(org.tensorflow.Tensor tensor, ImmutableOutputInfo<Regressor> outputIDInfo, int numValidFeatures, Example<Regressor> example) Converts aTensorinto aPrediction.org.tensorflow.TensorconvertToTensor(List<Example<Regressor>> examples, ImmutableOutputInfo<Regressor> outputIDInfo) Converts a list ofExampleinto aTensorrepresenting all the outputs in the list.org.tensorflow.TensorconvertToTensor(Regressor example, ImmutableOutputInfo<Regressor> outputIDInfo) Converts anOutputinto aTensorrepresenting it's output.static RegressorConverterdeserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.booleanbooleanDoes this OutputConverter generate probabilities.com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenanceThe type witness used when deserializing the TensorFlow model from a protobuf.inthashCode()BiFunction<org.tensorflow.op.Ops, com.oracle.labs.mlrg.olcut.util.Pair<org.tensorflow.op.core.Placeholder<? extends org.tensorflow.types.family.TNumber>, org.tensorflow.Operand<org.tensorflow.types.family.TNumber>>, org.tensorflow.Operand<org.tensorflow.types.family.TNumber>> loss()Returns a mean squared error loss.<U extends org.tensorflow.types.family.TNumber>
BiFunction<org.tensorflow.op.Ops, org.tensorflow.Operand<U>, org.tensorflow.op.Op> Applies the identity functionorg.tribuo.interop.tensorflow.protos.OutputConverterProtoSerializes this object to a protobuf.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.oracle.labs.mlrg.olcut.config.Configurable
postConfig
-
Field Details
-
CURRENT_VERSION
public static final int CURRENT_VERSIONProtobuf serialization version.- See Also:
-
-
Constructor Details
-
RegressorConverter
public RegressorConverter()Constructs a RegressorConverter.
-
-
Method Details
-
deserializeFromProto
public static RegressorConverter deserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.- Parameters:
version- The serialized object version.className- The class name.message- The serialized data.- Returns:
- The deserialized object.
-
serialize
public org.tribuo.interop.tensorflow.protos.OutputConverterProto serialize()Description copied from interface:ProtoSerializableSerializes this object to a protobuf.- Specified by:
serializein interfaceProtoSerializable<org.tribuo.interop.tensorflow.protos.OutputConverterProto>- Returns:
- The protobuf.
-
equals
-
hashCode
-
loss
public BiFunction<org.tensorflow.op.Ops, com.oracle.labs.mlrg.olcut.util.Pair<org.tensorflow.op.core.Placeholder<? extends org.tensorflow.types.family.TNumber>, org.tensorflow.Operand<org.tensorflow.types.family.TNumber>>, org.tensorflow.Operand<org.tensorflow.types.family.TNumber>> loss()Returns a mean squared error loss.- Specified by:
lossin interfaceOutputConverter<Regressor>- Returns:
- The mse loss.
-
outputTransformFunction
public <U extends org.tensorflow.types.family.TNumber> BiFunction<org.tensorflow.op.Ops, org.tensorflow.Operand<U>, org.tensorflow.op.Op> outputTransformFunction()Applies the identity function- Specified by:
outputTransformFunctionin interfaceOutputConverter<Regressor>- Type Parameters:
U- The input type (should be TFloat32).- Returns:
- A function which applies the identity function.
-
convertToPrediction
public Prediction<Regressor> convertToPrediction(org.tensorflow.Tensor tensor, ImmutableOutputInfo<Regressor> outputIDInfo, int numValidFeatures, Example<Regressor> example) Description copied from interface:OutputConverterConverts aTensorinto aPrediction.- Specified by:
convertToPredictionin interfaceOutputConverter<Regressor>- Parameters:
tensor- The tensor to convert.outputIDInfo- The output info to use to identify the outputs.numValidFeatures- The number of valid features used by the prediction.example- The example to insert into the prediction.- Returns:
- A prediction object.
-
convertToOutput
public Regressor convertToOutput(org.tensorflow.Tensor tensor, ImmutableOutputInfo<Regressor> outputIDInfo) Description copied from interface:OutputConverterConverts aTensorinto the specified output type.- Specified by:
convertToOutputin interfaceOutputConverter<Regressor>- Parameters:
tensor- The tensor to convert.outputIDInfo- The output info to use to identify the outputs.- Returns:
- A output.
-
convertToBatchPrediction
public List<Prediction<Regressor>> convertToBatchPrediction(org.tensorflow.Tensor tensor, ImmutableOutputInfo<Regressor> outputIDInfo, int[] numValidFeatures, List<Example<Regressor>> examples) Description copied from interface:OutputConverterConverts aTensorcontaining multiple outputs into a list ofPredictions.- Specified by:
convertToBatchPredictionin interfaceOutputConverter<Regressor>- Parameters:
tensor- The tensor to convert.outputIDInfo- The output info to use to identify the outputs.numValidFeatures- The number of valid features used by the prediction.examples- The example to insert into the prediction.- Returns:
- A list of predictions.
-
convertToBatchOutput
public List<Regressor> convertToBatchOutput(org.tensorflow.Tensor tensor, ImmutableOutputInfo<Regressor> outputIDInfo) Description copied from interface:OutputConverterConverts aTensorcontaining multiple outputs into a list ofOutputs.- Specified by:
convertToBatchOutputin interfaceOutputConverter<Regressor>- Parameters:
tensor- The tensor to convert.outputIDInfo- The output info to use to identify the outputs.- Returns:
- A list of outputs.
-
convertToTensor
public org.tensorflow.Tensor convertToTensor(Regressor example, ImmutableOutputInfo<Regressor> outputIDInfo) Description copied from interface:OutputConverterConverts anOutputinto aTensorrepresenting it's output.- Specified by:
convertToTensorin interfaceOutputConverter<Regressor>- Parameters:
example- The output to convert.outputIDInfo- The output info to use to identify the outputs.- Returns:
- A Tensor representing this output.
-
convertToTensor
public org.tensorflow.Tensor convertToTensor(List<Example<Regressor>> examples, ImmutableOutputInfo<Regressor> outputIDInfo) Description copied from interface:OutputConverterConverts a list ofExampleinto aTensorrepresenting all the outputs in the list. It accepts a list of Example rather than a list of Output for efficiency reasons.- Specified by:
convertToTensorin interfaceOutputConverter<Regressor>- Parameters:
examples- The examples to convert.outputIDInfo- The output info to use to identify the outputs.- Returns:
- A Tensor representing all the supplied Outputs.
-
generatesProbabilities
public boolean generatesProbabilities()Description copied from interface:OutputConverterDoes this OutputConverter generate probabilities.- Specified by:
generatesProbabilitiesin interfaceOutputConverter<Regressor>- Returns:
- True if it produces a probability distribution in the
Prediction.
-
toString
-
getProvenance
public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance()- Specified by:
getProvenancein interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>
-
getTypeWitness
Description copied from interface:OutputConverterThe type witness used when deserializing the TensorFlow model from a protobuf.The default implementation throws
UnsupportedOperationExceptionfor compatibility with implementations which don't use protobuf serialization. This implementation will be removed in the next major version of Tribuo.- Specified by:
getTypeWitnessin interfaceOutputConverter<Regressor>- Returns:
- The output class this object produces.
-