Class/Object

org.platanios.tensorflow.api.core

Graph

Related Docs: object Graph | package core

Permalink

class Graph extends utilities.Closeable with Serializable

Each graph uses a reentrant lock internally that protects its core state that can be returned via public accessors, as well as synchronizes session run calls with methods that create and mutate ops. This synchronization is necessary because it is illegal to modify an operation after it has been run. Thread-safety is provided on a best-effort basis to support buggy programs, and is not guaranteed by the public tf.Graph API. Note that the lock must be reentrant because methods that create and mutate ops may be called recursively due to control flow. Without a reentrant lock, many methods would also need a synchronized version or a lock parameter.

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Graph
  2. Serializable
  3. Closeable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def addToCollection[K](value: K, key: Key[K]): Unit

    Permalink

    Adds value to the collection with name key.

    Adds value to the collection with name key.

    value

    Value to add to the collection.

    key

    Collection name.

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def assertNotFrozen(): Unit

    Permalink

    Asserts that this graph has not been frozen.

    Asserts that this graph has not been frozen.

    Annotations
    @throws( ... )
  7. def clearCollection[K](key: Key[K]): Unit

    Permalink

    Removes the specified collection from this graph.

    Removes the specified collection from this graph.

    key

    Collection key.

  8. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def close(): Unit

    Permalink

    Releases the native resources associated with this object.

    Releases the native resources associated with this object.

    Definition Classes
    Closeable
  10. val closeFn: () ⇒ Unit

    Permalink
    Attributes
    protected
    Definition Classes
    GraphCloseable
  11. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  12. def equals(that: Any): Boolean

    Permalink
    Definition Classes
    Graph → AnyRef → Any
  13. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. def freeze(): Unit

    Permalink

    Freezes this graph, meaning that no more ops can be added to it after a call to this function.

    Freezes this graph, meaning that no more ops can be added to it after a call to this function. This method is used to ensure that no operations are added to a graph when it is shared between multiple threads.

  15. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  16. def getCollection[K](key: Key[K]): Set[K]

    Permalink

    Gets the set of values contained in the collection with name key.

    Gets the set of values contained in the collection with name key.

    Note that this method returns an immutable copy of the set.

    key

    Collection name.

    returns

    Set of values contained in the collection with name collection.

  17. def getOpByName(name: String): ops.Op

    Permalink

    Returns the op referred to by the provided name, in this graph.

    Returns the op referred to by the provided name, in this graph.

    If such an op cannot be found, an informative exception is thrown.

    name

    Op name.

    returns

    Op, from this graph, corresponding to that name.

    Annotations
    @throws( ... )
    Exceptions thrown

    InvalidArgumentException If the provided name cannot be associated with an element of this graph.

    Note

    This function may be called concurrently from multiple threads (i.e., it is thread-safe).

  18. def getOutputByName(name: String): ops.Output

    Permalink

    Returns the op output referred to by the provided name, in this graph.

    Returns the op output referred to by the provided name, in this graph.

    If such an op output cannot be found, an informative exception is thrown.

    name

    Op output name.

    returns

    Op output, from this graph, corresponding to that name.

    Annotations
    @throws( ... )
    Exceptions thrown

    InvalidArgumentException If the provided name cannot be associated with an element of this graph.

    Note

    This function may be called concurrently from multiple threads (i.e., it is thread-safe).

  19. def globalVariables: Set[ops.variables.Variable]

    Permalink

    Returns the set of global variables in this graph.

    Returns the set of global variables in this graph.

    Global variables are variables that are shared across machines in a distributed environment. The Variable() constructor and the function getVariable() automatically add new variables to the graph collection with key Graph.Keys.GLOBAL_VARIABLES. This convenience function returns the contents of that collection.

    An alternative to global variables are local variables.

  20. def globalVariablesInitializer(name: String = "GlobalVariablesInitializer"): ops.Op

    Permalink

    Returns an op that initializes all global variables of this graph.

    Returns an op that initializes all global variables of this graph.

    For more information, refer to globalVariables and Variable.initializer.

    name

    Name for the created op.

    returns

    Created op.

  21. def hashCode(): Int

    Permalink
    Definition Classes
    Graph → AnyRef → Any
  22. def importGraphDef(graphDef: GraphDef, importScope: String = null, inputsMap: Map[(String, Int), ops.Output] = Map.empty, controlDependenciesMap: Map[String, ops.Op] = Map.empty, controlDependencies: Set[ops.Op] = Set.empty): Unit

    Permalink

    Imports a serialized representation of a graph into the current graph.

    Imports a serialized representation of a graph into the current graph.

    graphDef

    Serialized representation of the graph that will be imported into this graph.

    importScope

    Optional prefix that will be prepended to all node names in the graph that is being imported to this graph.

    inputsMap

    Optional inputs mapping. For each (source_op_name, source_op_output_index) -> destination_op_output mapping, the importer will set any imported nodes with input named source_op_name:source_op_output_index to have that input replaced with destination_op_output. source_op_name refers to a node in the graph to be imported, whereas destination_op_output references a node already existing in this graph.

    controlDependenciesMap

    Optional control dependencies mapping. For each source_op_name -> destination_op mapping, the importer will set any imported ops with control input named source_op_name to have that input replaced with destination_op. source_op_name refers to a node in the graph to be imported, whereas destination_op references an op already existing in this graph.

    controlDependencies

    Optional control dependencies set. The importer will make sure that the imported graph has a control dependency on all ops in this set. All such ops, should therefore be defined in this graph.

  23. def importMetaGraphDef(metaGraphDef: MetaGraphDef, importScope: String = null, inputsMap: Map[(String, Int), ops.Output] = Map.empty, controlDependenciesMap: Map[String, ops.Op] = Map.empty, controlDependencies: Set[ops.Op] = Set.empty, clearDevices: Boolean = false, unboundInputsCollectionKey: Key[String] = Graph.Keys.UNBOUND_INPUTS, restoreCollectionsPredicate: (Key[_]) ⇒ Boolean = _ => true): Unit

    Permalink

    Imports a serialized representation of a graph and its meta-information into the current graph.

    Imports a serialized representation of a graph and its meta-information into the current graph.

    This function takes a MetaGraphDef protocol buffer as input and it adds all the nodes from its graph_def field to the current graph. It also recreates the desired collections stored in that protocol buffer.

    In combination with toMetaGraphDef, this function can be used to:

    • Serialize a graph along with other objects stored in its collections, into a MetaGraphDef.
    • Restart training from saved graphs and checkpoints.
    • Run inference from saved graphs and checkpoints.
    metaGraphDef

    Serialized representation of the graph and its meta-information, that will be imported into this graph.

    importScope

    Optional prefix that will be prepended to all node names in the graph that is being imported to this graph.

    inputsMap

    Optional inputs mapping. For each (source_op_name, source_op_output_index) -> destination_op_output mapping, the importer will set any imported nodes with input named source_op_name:source_op_output_index to have that input replaced with destination_op_output. source_op_name refers to a node in the graph to be imported, whereas destination_op_output references a node already existing in this graph.

    controlDependenciesMap

    Optional control dependencies mapping. For each source_op_name -> destination_op mapping, the importer will set any imported ops with control input named source_op_name to have that input replaced with destination_op. source_op_name refers to a node in the graph to be imported, whereas destination_op references an op already existing in this graph.

    controlDependencies

    Optional control dependencies set. The importer will make sure that the imported graph has a control dependency on all ops in this set. All such ops, should therefore be defined in this graph.

    clearDevices

    Boolean value indicating whether to clear the device information from the returned node definition.

    unboundInputsCollectionKey

    Collection key for looking up unbound inputs.

    restoreCollectionsPredicate

    Function that takes as input a graph collection key and returns a boolean value indicating whether or not to load that collection. Note that the collection specified by unboundInputsCollectionKey is never loaded. Defaults to a function that returns true for all inputs.

  24. def isClosed: Boolean

    Permalink

    Returns true if this graph has been closed (meaning that the corresponding native object has been deleted).

  25. def isFrozen: Boolean

    Permalink

    Returns a boolean flag indicating whether this graph has been frozen (i.e., no more ops can be added to it).

  26. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  27. def localResources: Set[Resource]

    Permalink

    Returns the set of all local resources used by the graph which need to be initialized once per cluster.

  28. def localVariables: Set[ops.variables.Variable]

    Permalink

    Returns the set of local variables in this graph.

    Returns the set of local variables in this graph.

    Local variables (or per-process variables), are usually not saved/restored to/from checkpoints and are used for temporary or intermediate values. For example, they can be used as counters for metrics computations or number of epochs this machine has read data. This convenience function returns the contents of that collection.

    An alternative to local variables are global variables.

  29. def localVariablesInitializer(name: String = "LocalVariablesInitializer"): ops.Op

    Permalink

    Returns an op that initializes all local variables of this graph.

    Returns an op that initializes all local variables of this graph.

    For more information, refer to localVariables and Variable.initializer.

    name

    Name for the created op.

    returns

    Created op.

  30. def metricVariables: Set[ops.variables.Variable]

    Permalink

    Returns the set of metric variables in the current graph.

    Returns the set of metric variables in the current graph.

    Metric variables are usually not saved/restored to/from checkpoints and are used for temporary or intermediate values used for computing metrics (e.g., streaming metrics). This convenience function returns the contents of that collection.

  31. def metricVariablesInitializer(name: String = "MetricVariablesInitializer"): ops.Op

    Permalink

    Returns an op that initializes all metric variables of this graph.

    Returns an op that initializes all metric variables of this graph.

    For more information, refer to metricVariables and Variable.initializer.

    name

    Name for the created op.

    returns

    Created op.

  32. def modelVariables: Set[ops.variables.Variable]

    Permalink

    Returns the subset of Variable objects that are used in models for inference (feed forward), in this graph.

  33. def modelVariablesInitializer(name: String = "ModelVariablesInitializer"): ops.Op

    Permalink

    Returns an op that initializes all model variables of this graph.

    Returns an op that initializes all model variables of this graph.

    For more information, refer to modelVariables and Variable.initializer.

    name

    Name for the created op.

    returns

    Created op.

  34. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  35. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  36. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  37. def ops: Array[ops.Op]

    Permalink

    Returns all ops of this graph.

    Returns all ops of this graph.

    returns

    Array containing all ops of this graph.

    Note

    This function may be called concurrently from multiple threads (i.e., it is thread-safe).

  38. def randomSeed: Option[Int]

    Permalink

    Gets the random seed of this graph.

  39. def savers: Set[Saver]

    Permalink

    Returns the set of all savers that have been created in the graph.

  40. def setRandomSeed(value: Int): Unit

    Permalink

    Sets the random seed of this graph to the provided value.

  41. def sharedResources: Set[Resource]

    Permalink

    Returns the set of all shared resources used by the graph which need to be initialized once per cluster.

  42. def summaries: Set[ops.Output]

    Permalink

    Returns the set of all the summary Outputs that have been created in the graph.

  43. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  44. def tableInitializers: Set[ops.Op]

    Permalink

    Returns the set of all the table initializers that have been created in the graph.

  45. def toGraphDef: GraphDef

    Permalink

    Constructs and returns a GraphDef object, which is a serialized version of this graph.

    Constructs and returns a GraphDef object, which is a serialized version of this graph.

    Note that the GraphDef does not contain any meta-information about the graph (such as collections information, for example). For a serialized representation of the graph that contains such information, please refer to Graph.toMetaGraphDef.

  46. def toMetaGraphDef(exportScope: String = null, metaInfoDef: MetaInfoDef = null, saverDef: SaverDef = null, collections: Set[Key[_]] = Set.empty, unboundInputsCollectionKey: Key[String] = Graph.Keys.UNBOUND_INPUTS, clearDevices: Boolean = false): MetaGraphDef

    Permalink

    Constructs and returns a MetaGraphDef object using the provided arguments.

    Constructs and returns a MetaGraphDef object using the provided arguments.

    In combination with importMetaGraphDef, this function can be used to:

    • Serialize a graph along with other objects stored in its collections, into a MetaGraphDef.
    • Restart training from saved graphs and checkpoints.
    • Run inference from saved graphs and checkpoints.
    exportScope

    Optional string specifying the name scope to remove. Only the ops within this name scope will be included in the resulting ProtoBuf object and the export scope will be stripped from their names to allow for easy import into new name scopes.

    metaInfoDef

    MetaInfoDef associated with the MetaGraphDef that will be constructed.

    saverDef

    SaverDef associated with the MetaGraphDef that will be constructed.

    collections

    Graph collection keys specifying the collections to include in the MetaGraphDef.

    unboundInputsCollectionKey

    Collection key for storing unbound inputs. If provided, a string collection with the given name will be added to the returned MetaGraphDef, containing the names of tensors that must be remapped when importing the MetaGraphDef.

    clearDevices

    Boolean value indicating whether to clear the device information from the returned node definitions.

    returns

    Constructed MetaGraphDef.

  47. def toProto: GraphDef

    Permalink

    Constructs and returns a GraphDef object, which is a serialized version of this graph.

    Constructs and returns a GraphDef object, which is a serialized version of this graph.

    Note that the GraphDef does not contain any meta-information about the graph (such as collections information, for example). For a serialized representation of the graph that contains such information, please refer to Graph.toMetaGraphDef.

    returns

    ProtoBuf object corresponding to this object.

    Definition Classes
    GraphSerializable
  48. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  49. def trainOps: Set[ops.Op]

    Permalink

    Returns the set of all the train Ops (i.e., optimizer update ops) that have been created in the graph.

  50. def trainableVariables: Set[ops.variables.Variable]

    Permalink

    Returns the set of all variables created with trainable = true.

    Returns the set of all variables created with trainable = true.

    When passed trainable = true, the Variable() constructor automatically adds new variables to the graph collection with key Graph.Keys.TRAINABLE_VARIABLES. This convenience function returns the contents of that collection.

  51. def trainableVariablesInitializer(name: String = "TrainableVariablesInitializer"): ops.Op

    Permalink

    Returns an op that initializes all trainable variables of this graph.

    Returns an op that initializes all trainable variables of this graph.

    For more information, refer to trainableVariables and Variable.initializer.

    name

    Name for the created op.

    returns

    Created op.

  52. def unFreeze(): Unit

    Permalink

    Unfreezes this graph.

  53. def uninitializedResources(name: String = "UninitializedResources"): ops.Output

    Permalink

    Creates an op that returns a tensor containing the names of all uninitialized resources among all shared and local resources of this graph.

    Creates an op that returns a tensor containing the names of all uninitialized resources among all shared and local resources of this graph. If all resources have been initialized, then an empty tensor is returned.

    name

    Name for the created op.

    returns

    Created op output, which contains the names of the handles of all resources which have not yet been initialized.

  54. def uninitializedVariables(name: String = "UninitializedVariables"): ops.Output

    Permalink

    Creates an op that returns a tensor containing the names of all uninitialized variables among all global and local variables of this graph.

    Creates an op that returns a tensor containing the names of all uninitialized variables among all global and local variables of this graph. If all variables have been initialized, then an empty tensor is returned.

    name

    Name for the created op.

    returns

    Created op output, which contains the names of the handles of all variables which have not yet been initialized.

  55. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  56. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  57. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from utilities.Closeable

Inherited from AnyRef

Inherited from Any

Ungrouped