Package org.tribuo.interop.tensorflow
Class ImageConverter
java.lang.Object
org.tribuo.interop.tensorflow.ImageConverter
- 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
,FeatureConverter
,ProtoSerializable<org.tribuo.interop.tensorflow.protos.FeatureConverterProto>
Image converter. Assumes the feature id numbers are linearised ids of the form:
[0,0,0] = 0, [0,0,1] = 1, [0,1,0] = k, [1,0,0] = j*k, ..., [i,0,0] = i*j*k,That is, they are in multidimensional row major order (e.g. the order used by
IDXDataSource
).- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Protobuf serialization version.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
-
Constructor Summary
ConstructorDescriptionImageConverter
(String inputName, int width, int height, int channels) Builds an image converter for images of the supplied size. -
Method Summary
Modifier and TypeMethodDescriptionconvert
(List<? extends Example<?>> examples, ImmutableFeatureMap featureIDMap) Transform implicitly pads unseen values with zero.convert
(Example<?> example, ImmutableFeatureMap featureIDMap) Transform implicitly pads unseen values with zero.static ImageConverter
deserializeFromProto
(int version, String className, com.google.protobuf.Any message) Deserialization factory.com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance
Gets a view of the names of the inputs this converter produces.void
Used by the OLCUT configuration system, and should not be called by external code.org.tribuo.interop.tensorflow.protos.FeatureConverterProto
Serializes this object to a protobuf.toString()
-
Field Details
-
CURRENT_VERSION
public static final int CURRENT_VERSIONProtobuf serialization version.- See Also:
-
-
Constructor Details
-
ImageConverter
Builds an image converter for images of the supplied size.- Parameters:
inputName
- The input name.width
- The image width.height
- The image height.channels
- The number of colour channels.
-
-
Method Details
-
postConfig
public void postConfig()Used by the OLCUT configuration system, and should not be called by external code.- Specified by:
postConfig
in interfacecom.oracle.labs.mlrg.olcut.config.Configurable
-
deserializeFromProto
public static ImageConverter deserializeFromProto(int version, String className, com.google.protobuf.Any message) throws com.google.protobuf.InvalidProtocolBufferException Deserialization factory.- Parameters:
version
- The serialized object version.className
- The class name.message
- The serialized data.- Returns:
- The deserialized object.
- Throws:
com.google.protobuf.InvalidProtocolBufferException
- If the protobuf could not be parsed from themessage
.
-
serialize
public org.tribuo.interop.tensorflow.protos.FeatureConverterProto serialize()Description copied from interface:ProtoSerializable
Serializes this object to a protobuf.- Specified by:
serialize
in interfaceProtoSerializable<org.tribuo.interop.tensorflow.protos.FeatureConverterProto>
- Returns:
- The protobuf.
-
inputNamesSet
Description copied from interface:FeatureConverter
Gets a view of the names of the inputs this converter produces.- Specified by:
inputNamesSet
in interfaceFeatureConverter
- Returns:
- The input names.
-
convert
Transform implicitly pads unseen values with zero.- Specified by:
convert
in interfaceFeatureConverter
- Parameters:
example
- The example to transform.featureIDMap
- The feature id mapping to use.- Returns:
- A 4d tensor, (1, width, height, channels) for this example.
-
convert
Transform implicitly pads unseen values with zero.Converts a batch of examples into a Tensor.
- Specified by:
convert
in interfaceFeatureConverter
- Parameters:
examples
- The examples to transform.featureIDMap
- The feature id mapping to use.- Returns:
- A 4d tensor, (batch-id, width, height, channels) for this example.
-
convert
Description copied from interface:FeatureConverter
Converts aSGDVector
representing the features into aTensorMap
.It generates it as a single example minibatch.
- Specified by:
convert
in interfaceFeatureConverter
- Parameters:
vector
- The features to convert.- Returns:
- A TensorMap (similar to a TF Python feed_dict) representing this vector.
-
convert
Description copied from interface:FeatureConverter
- Specified by:
convert
in interfaceFeatureConverter
- Parameters:
vectors
- The batch of features to convert.- Returns:
- A TensorMap (similar to a TF Python feed_dict) representing this minibatch.
-
toString
-
getProvenance
public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance()- Specified by:
getProvenance
in interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>
-