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

public class DenseFeatureConverter extends Object implements FeatureConverter
Converts a sparse example into a dense float vector, then wraps it in a TFloat32.
See Also:
  • Field Details

    • THRESHOLD

      public static final int THRESHOLD
      Feature 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_THRESHOLD
      Number of times the feature size warning should be printed.
      See Also:
  • Constructor Details

    • DenseFeatureConverter

      public DenseFeatureConverter(String inputName)
      Builds a DenseFeatureConverter, setting the input name.
      Parameters:
      inputName - The placeholder input name.
  • Method Details

    • convert

      public TensorMap convert(Example<?> example, ImmutableFeatureMap featureIDMap)
      Description copied from interface: FeatureConverter
      Converts an Example into a TensorMap suitable for supplying as an input to a graph.

      It generates it as a single example minibatch.

      Specified by:
      convert in interface FeatureConverter
      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

      public TensorMap convert(List<? extends Example<?>> examples, ImmutableFeatureMap featureIDMap)
      Description copied from interface: FeatureConverter
      Converts a batch of Examples into a single TensorMap suitable for supplying as an input to a graph.
      Specified by:
      convert in interface FeatureConverter
      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

      public TensorMap convert(SGDVector vector)
      Description copied from interface: FeatureConverter
      Converts a SGDVector representing the features into a TensorMap.

      It generates it as a single example minibatch.

      Specified by:
      convert in interface FeatureConverter
      Parameters:
      vector - The features to convert.
      Returns:
      A TensorMap (similar to a TF Python feed_dict) representing this vector.
    • convert

      public TensorMap convert(List<? extends SGDVector> vectors)
      Description copied from interface: FeatureConverter
      Converts a list of SGDVectors representing a batch of features into a TensorMap.
      Specified by:
      convert in interface FeatureConverter
      Parameters:
      vectors - The batch of features to convert.
      Returns:
      A TensorMap (similar to a TF Python feed_dict) representing this minibatch.
    • inputNamesSet

      public Set<String> inputNamesSet()
      Description copied from interface: FeatureConverter
      Gets a view of the names of the inputs this converter produces.
      Specified by:
      inputNamesSet in interface FeatureConverter
      Returns:
      The input names.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getProvenance

      public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance()
      Specified by:
      getProvenance in interface com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>