Class TensorMap

java.lang.Object
org.tribuo.interop.tensorflow.TensorMap
All Implemented Interfaces:
AutoCloseable

public final class TensorMap extends Object implements AutoCloseable
A map of names and tensors to feed into a session.
  • Constructor Summary

    Constructors
    Constructor
    Description
    TensorMap(String inputName, org.tensorflow.Tensor value)
    Creates a TensorMap containing the supplied mapping.
    TensorMap(Map<String,org.tensorflow.Tensor> map)
    Creates a new TensorMap wrapping the supplied map.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    org.tensorflow.Session.Runner
    feedInto(org.tensorflow.Session.Runner runner)
    Feeds the tensors in this FeedDict into the runner.
    Map<String,org.tensorflow.Tensor>
    Returns the underlying immutable map.
    Optional<org.tensorflow.Tensor>
    Returns the specified tensor if present.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TensorMap

      public TensorMap(String inputName, org.tensorflow.Tensor value)
      Creates a TensorMap containing the supplied mapping.
      Parameters:
      inputName - The input name.
      value - The tensor value.
    • TensorMap

      public TensorMap(Map<String,org.tensorflow.Tensor> map)
      Creates a new TensorMap wrapping the supplied map.
      Parameters:
      map - A map from strings to tensors.
  • Method Details

    • getMap

      public Map<String,org.tensorflow.Tensor> getMap()
      Returns the underlying immutable map.
      Returns:
      The map.
    • getTensor

      public Optional<org.tensorflow.Tensor> getTensor(String key)
      Returns the specified tensor if present.
      Parameters:
      key - The key to lookup.
      Returns:
      An optional containing the specified tensor if it's in the map, an empty optional otherwise.
    • feedInto

      public org.tensorflow.Session.Runner feedInto(org.tensorflow.Session.Runner runner)
      Feeds the tensors in this FeedDict into the runner.

      If the session does not have placeholders with the names used in this TensorMap then the Session.Runner will throw IllegalArgumentException.

      Parameters:
      runner - The session runner.
      Returns:
      The runner.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • toString

      public String toString()
      Overrides:
      toString in class Object