Package org.tribuo.interop.onnx
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
Converts a sparse Tribuo example into a dense float vector, then wraps it in an
OnnxTensor
.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Feature size beyond which a warning is generated (as ONNX requires dense features and large feature spaces are memory hungry).static final int
Number of times the feature size warning should be printed. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncom.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance
toString()
ai.onnxruntime.OnnxTensor
transform
(ai.onnxruntime.OrtEnvironment env, List<SparseVector> vectors) Converts a list ofSparseVector
s representing a batch of features into aOnnxTensor
.ai.onnxruntime.OnnxTensor
transform
(ai.onnxruntime.OrtEnvironment env, SparseVector vector) Converts aSparseVector
representing the features into aOnnxTensor
.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
-
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()
-
-
Method Details
-
transform
public ai.onnxruntime.OnnxTensor transform(ai.onnxruntime.OrtEnvironment env, SparseVector vector) throws ai.onnxruntime.OrtException Description copied from interface:ExampleTransformer
Converts aSparseVector
representing the features into aOnnxTensor
.It generates it as a single example minibatch.
- Specified by:
transform
in 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:ExampleTransformer
Converts a list ofSparseVector
s representing a batch of features into aOnnxTensor
.- Specified by:
transform
in 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
-
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>
-