Class

org.platanios.tensorflow.api.ops.variables

Variable

Related Doc: package variables

Permalink

case class Variable extends Serializable with VariableLike with Product with Serializable

Variable based on resource handles.

See the Variables Guide for a high-level overview.

A variable allows you to maintain state across subsequent calls to Session.run(). The variable constructors require an initial value for the variable, which can be a tensor of any type and shape. The initial value defines the type and shape of the variable. After construction, the type and shape of the variable are fixed. The value can be changed using one of the assignment methods.

Just like any tensor, variables can be used as inputs for other ops in the graph. Additionally, all the operators overloaded for tensors are carried over to variables, so you can also add nodes to the graph by just doing arithmetic on variables.

Unlike the Python API, the Scala API uses resource variables that have well-defined semantics. Each usage of a resource variable in a TensorFlow graph adds a read operation to the graph. The tensors returned by a read operation are guaranteed to see all modifications to the value of the variable which happen in any operation on which the read depends on (either directly, indirectly, or via a control dependency) and guaranteed to not see any modification to the value of the variable from operations that depend on the read operation. Updates from operations that have no dependency relationship to the read operation might or might not be visible to read. For example, if there is more than one assignment to a resource variable in a single Session.run() call there is a well-defined value for each operation which uses the variable's value if the assignments and the read are connected by edges in the graph.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Variable
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. VariableLike
  7. OutputConvertible
  8. Serializable
  9. AnyRef
  10. 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. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def assign(value: Output, name: String = "Assign"): Output

    Permalink

    Creates an op that assigns the provided value to this variable and returns its value.

    Creates an op that assigns the provided value to this variable and returns its value.

    value

    Value to assign the variable to.

    name

    Name for created op.

    returns

    Variable value read op, after the assignment.

    Definition Classes
    VariableVariableLike
    Annotations
    @throws( ... )
  6. def assignAdd(value: Output, name: String = "AssignAdd"): Output

    Permalink

    Creates an op that adds the provided value to the current value of the variable and returns its value.

    Creates an op that adds the provided value to the current value of the variable and returns its value.

    value

    Value to add to the current variable value.

    name

    Name for created op.

    returns

    Variable value read op, after the addition.

    Definition Classes
    VariableVariableLike
    Annotations
    @throws( ... ) @throws( ... )
  7. def assignScatter(indices: Output, values: Output, name: String = "AssignScatter"): Output

    Permalink

    Creates an op that applies updates the provided sparse value updates to this variable and returns its value.

    Creates an op that applies updates the provided sparse value updates to this variable and returns its value.

    indices

    Indices corresponding to the values used for the update.

    values

    Values to use for updating, corresponding to the provided indices.

    name

    Name for created op.

    returns

    Variable value read op, after the addition.

    Definition Classes
    VariableVariableLike
    Annotations
    @throws( ... ) @throws( ... )
  8. def assignScatterAdd(indices: Output, values: Output, name: String = "AssignScatterAdd"): Output

    Permalink

    Creates an op that adds the provided sparse value to the current value of the variable and returns its value.

    Creates an op that adds the provided sparse value to the current value of the variable and returns its value.

    indices

    Indices corresponding to the values being added.

    values

    Values to be added, corresponding to the provided indices.

    name

    Name for created op.

    returns

    Variable value read op, after the addition.

    Definition Classes
    VariableVariableLike
    Annotations
    @throws( ... ) @throws( ... )
  9. def assignScatterSub(indices: Output, values: Output, name: String = "AssignScatterSub"): Output

    Permalink

    Creates an op that subtracts the provided sparse value from the current value of the variable and returns its value.

    Creates an op that subtracts the provided sparse value from the current value of the variable and returns its value.

    indices

    Indices corresponding to the values being subtracted.

    values

    Values to be subtracted, corresponding to the provided indices.

    name

    Name for created op.

    returns

    Variable value read op, after the subtraction.

    Definition Classes
    VariableVariableLike
    Annotations
    @throws( ... ) @throws( ... )
  10. def assignSub(value: Output, name: String = "AssignAdd"): Output

    Permalink

    Creates an op that subtracts the provided value from the current value of the variable and returns its value.

    Creates an op that subtracts the provided value from the current value of the variable and returns its value.

    value

    Value to subtract from the current variable value.

    name

    Name for created op.

    returns

    Variable value read op, after the subtraction.

    Definition Classes
    VariableVariableLike
    Annotations
    @throws( ... ) @throws( ... )
  11. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. val dataType: types.DataType

    Permalink

    Data type of this variable.

    Data type of this variable.

    Definition Classes
    VariableVariableLike
  13. val device: String

    Permalink

    Device where this variable resides.

  14. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    Variable → Equals → AnyRef → Any
  16. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  17. def gather(indices: Output, name: String = "Gather"): Output

    Permalink

    Creates an op that reads the value of this variable sparsely, using the provided indices.

    Creates an op that reads the value of this variable sparsely, using the provided indices.

    This method should be used when there are multiple reads, or when it is desirable to read the value only after some condition is true.

    indices

    Indices to use for the sparse read.

    name

    Name for the created op.

    returns

    Created op.

    Definition Classes
    VariableVariableLike
    Annotations
    @throws( ... )
  18. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  19. val graph: core.Graph

    Permalink

    Graph where this variable is defined.

    Graph where this variable is defined.

    Definition Classes
    VariableVariableLike
  20. def hashCode(): Int

    Permalink
    Definition Classes
    Variable → AnyRef → Any
  21. val initializedValue: Output

    Permalink

    Value of the initialized variable.

    Value of the initialized variable. You should use this instead of the variable itself to initialize another variable with a value that depends on the value of this variable.

    Example:

    // Initialize `v` with random values, and then use `initializedValue` to guarantee that `v` has been initialized
    // before its value is used to initialize `w`. The random tensor will only be sampled once.
    val v = tf.variable("v", FLOAT32, Shape(10, 40), tf.RandomTruncatedNormalInitializer())
    val w = tf.variable("w", initializer = tf.ConstantInitializer(v.initializedValue * 2.0))
    Definition Classes
    VariableVariableLike
  22. val initializer: api.Op

    Permalink

    Op responsible for initializing this variable.

    Op responsible for initializing this variable.

    Definition Classes
    VariableVariableLike
  23. val isInitialized: Output

    Permalink

    Op output that is true when the variable has been initialized and false otherwise.

    Op output that is true when the variable has been initialized and false otherwise.

    Definition Classes
    VariableVariableLike
  24. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  25. val name: String

    Permalink

    Name of this variable.

    Name of this variable.

    Definition Classes
    VariableVariableLike
  26. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  29. val op: api.Op

    Permalink

    Op corresponding to this variable.

  30. def read(name: String = "Read"): Output

    Permalink

    Creates an op that reads the value of this variable.

    Creates an op that reads the value of this variable.

    This method should be used when there are multiple reads, or when it is desirable to read the value only after some condition is true.

    The returned value may be different from that of value depending on the device being used, the control dependencies, etc.

    returns

    Created op.

    Definition Classes
    VariableVariableLike
  31. val shape: core.Shape

    Permalink

    Shape of this variable.

    Shape of this variable.

    Definition Classes
    VariableVariableLike
  32. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  33. def toOutput: Output

    Permalink

    Converts this variable to an op output.

    Converts this variable to an op output. This function simply returns an op corresponding to the variable value.

    Definition Classes
    VariableLikeOutputConvertible
  34. def toProto(exportScope: String): VariableDef

    Permalink

    Alias for toVariableDef.

  35. def toProto: VariableDef

    Permalink

    Converts this object to its corresponding ProtoBuf object.

    Converts this object to its corresponding ProtoBuf object.

    returns

    ProtoBuf object corresponding to this object.

    Definition Classes
    VariableSerializable
  36. def toString(): String

    Permalink
    Definition Classes
    Variable → AnyRef → Any
  37. def toVariableDef(exportScope: String): VariableDef

    Permalink

    Convert this object to its corresponding ProtoBuf object.

    Convert this object to its corresponding ProtoBuf object.

    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.

    returns

    ProtoBuf object corresponding to this object.

  38. val value: Output

    Permalink

    Cached op which reads the last value of this variable.

    Cached op which reads the last value of this variable.

    You can not assign a new value to the returned tensor as it is not a reference to the variable.

    NOTE: You usually do not need to call this method directly, as all ops that use variables do so by internally converting them to tensors.

    Definition Classes
    VariableVariableLike
  39. final def wait(): Unit

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

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

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

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from VariableLike

Inherited from OutputConvertible

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped