Package org.tribuo.interop.tensorflow
Class DenseFeatureConverter
java.lang.Object
org.tribuo.interop.tensorflow.DenseFeatureConverter
- 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>
Converts a sparse example into a dense float vector, then wraps it in a
TFloat32
.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Protobuf serialization version.static final int
Feature size beyond which a warning is generated (as TensorFlow requires dense features and large feature spaces are memory hungry).static final int
Number of times the feature size warning should be printed.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
-
Constructor Summary
ConstructorDescriptionDenseFeatureConverter
(String inputName) Builds a DenseFeatureConverter, setting the input name. -
Method Summary
Modifier and TypeMethodDescriptionconvert
(List<? extends Example<?>> examples, ImmutableFeatureMap featureIDMap) convert
(Example<?> example, ImmutableFeatureMap featureIDMap) static DenseFeatureConverter
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.org.tribuo.interop.tensorflow.protos.FeatureConverterProto
Serializes this object to a protobuf.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:
-
THRESHOLD
public static final int THRESHOLDFeature size beyond which a warning is generated (as TensorFlow requires dense features and large feature spaces are memory hungry).- See Also:
-
WARNING_THRESHOLD
public static final int WARNING_THRESHOLDNumber of times the feature size warning should be printed.- See Also:
-
-
Constructor Details
-
DenseFeatureConverter
Builds a DenseFeatureConverter, setting the input name.- Parameters:
inputName
- The placeholder input name.
-
-
Method Details
-
deserializeFromProto
public static DenseFeatureConverter 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.
-
convert
Description copied from interface:FeatureConverter
Converts anExample
into aTensorMap
suitable for supplying as an input to a graph.It generates it as a single example minibatch.
- Specified by:
convert
in interfaceFeatureConverter
- Parameters:
example
- The example to convert.featureIDMap
- The id map to convert feature names into id numbers.- Returns:
- A TensorMap (similar to a TF Python feed_dict) representing the features in this example.
-
convert
Description copied from interface:FeatureConverter
- Specified by:
convert
in interfaceFeatureConverter
- Parameters:
examples
- The examples to convert.featureIDMap
- THe id map to convert feature names into id numbers.- Returns:
- A TensorMap (similar to a TF Python feed_dict) representing the features in this minibatch.
-
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.
-
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.
-
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>
-