Class DenseTransformer
java.lang.Object
org.tribuo.interop.onnx.DenseTransformer
- 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,ExampleTransformer,ProtoSerializable<org.tribuo.interop.onnx.protos.ExampleTransformerProto>
Converts a sparse Tribuo example into a dense float vector, then wraps it in an
OnnxTensor.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intProtobuf serialization version.static final intFeature size beyond which a warning is generated (as ONNX requires dense features and large feature spaces are memory hungry).static final intNumber of times the feature size warning should be printed.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a transformer which converts Tribuo sparse vectors into a dense tensor. -
Method Summary
Modifier and TypeMethodDescriptionstatic DenseTransformerdeserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.booleancom.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenanceinthashCode()org.tribuo.interop.onnx.protos.ExampleTransformerProtoSerializes this object to a protobuf.toString()ai.onnxruntime.OnnxTensortransform(ai.onnxruntime.OrtEnvironment env, List<SparseVector> vectors) Converts a list ofSparseVectors representing a batch of features into aOnnxTensor.ai.onnxruntime.OnnxTensortransform(ai.onnxruntime.OrtEnvironment env, SparseVector vector) Converts aSparseVectorrepresenting the features into aOnnxTensor.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:
-
THRESHOLD
public static final int THRESHOLDFeature size beyond which a warning is generated (as ONNX 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
-
DenseTransformer
public DenseTransformer()Construct a transformer which converts Tribuo sparse vectors into a dense tensor.
-
-
Method Details
-
deserializeFromProto
public static DenseTransformer 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.
-
transform
public ai.onnxruntime.OnnxTensor transform(ai.onnxruntime.OrtEnvironment env, SparseVector vector) throws ai.onnxruntime.OrtException Description copied from interface:ExampleTransformerConverts aSparseVectorrepresenting the features into aOnnxTensor.It generates it as a single example minibatch.
- Specified by:
transformin interfaceExampleTransformer- Parameters:
env- The OrtEnvironment to create the tensor in.vector- The features to convert.- Returns:
- A dense OnnxTensor representing this vector.
- Throws:
ai.onnxruntime.OrtException- if the transformation failed.
-
transform
public ai.onnxruntime.OnnxTensor transform(ai.onnxruntime.OrtEnvironment env, List<SparseVector> vectors) throws ai.onnxruntime.OrtException Description copied from interface:ExampleTransformerConverts a list ofSparseVectors representing a batch of features into aOnnxTensor.- Specified by:
transformin interfaceExampleTransformer- Parameters:
env- The OrtEnvironment to create the tensor in.vectors- The batch of features to convert.- Returns:
- A dense OnnxTensor representing this minibatch.
- Throws:
ai.onnxruntime.OrtException- if the transformation failed.
-
toString
-
equals
-
hashCode
-
serialize
public org.tribuo.interop.onnx.protos.ExampleTransformerProto serialize()Description copied from interface:ProtoSerializableSerializes this object to a protobuf.- Specified by:
serializein interfaceProtoSerializable<org.tribuo.interop.onnx.protos.ExampleTransformerProto>- Returns:
- The protobuf.
-
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>
-