Package

org.platanios.tensorflow.api.ops

variables

Permalink

package variables

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. variables
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. final class CheckpointStateProto extends AnyRef

    Permalink
  2. case class ConstantInitializer(value: tensors.Tensor[types.DataType]) extends Initializer with Product with Serializable

    Permalink

    Initializer that sets the value of the variable to the provided value.

  3. case class DynamicConstantInitializer(value: Output) extends Initializer with Product with Serializable

    Permalink

    Initializer that sets the value of the variable to the provided value.

  4. case class GlorotNormalInitializer(seed: Option[Int] = None) extends VarianceScalingInitializer with Product with Serializable

    Permalink

    Glorot Normal initializer, also called the Xavier Normal initializer..

    Glorot Normal initializer, also called the Xavier Normal initializer..

    This initializer draws samples from a Normal distribution centered on zero and with standard deviation equal to sqrt(2 / (fanIn + fanOut)), where fanIn is the number of input units in the weight tensor and fanOut is the number of output units in the weight tensor.

    Reference: [Understanding the difficulty of training deep feed-forward neural networks](http://jmlr.org/proceedings/papers/v9/glorot10a/glorot10a.pdf)

    seed

    Optional random seed, used to generate a random seed pair for the random number generator, when combined with the graph-level seed.

  5. case class GlorotUniformInitializer(seed: Option[Int] = None) extends VarianceScalingInitializer with Product with Serializable

    Permalink

    Glorot uniform initializer, also called the Xavier uniform initializer..

    Glorot uniform initializer, also called the Xavier uniform initializer..

    This initializer draws samples from a uniform distribution within [-limit, limit], where limit is equal to sqrt(6 / (fanIn + fanOut)), where fanIn is the number of input units in the weight tensor and fanOut is the number of output units in the weight tensor.

    Reference: [Understanding the difficulty of training deep feed-forward neural networks](http://jmlr.org/proceedings/papers/v9/glorot10a/glorot10a.pdf)

    seed

    Optional random seed, used to generate a random seed pair for the random number generator, when combined with the graph-level seed.

  6. trait Initializer extends AnyRef

    Permalink

    Base trait for all variable initializers.

  7. case class PartitionedVariable extends Iterable[Variable] with VariableLike with Product with Serializable

    Permalink

    Partitioned variable wrapper.

    Partitioned variable wrapper.

    Variables passed via wrappedVariables must contain a non-null save slice information field. Concatenation and iteration is in lexicographic order according to the variableOffset property of the save slice information.

    Accessing this object as an Output returns the variable parts concatenated along the partition axis.

    This wrapper also acts as an iterator that allows accessing the underlying variables. This iterator is necessary to control the order of access when variables are not partitioned in a standard way along a single axis.

    Annotations
    @throws( ... )
    Exceptions thrown

    IllegalArgumentException If the provided variables sequence is empty, or if their shapes do not match with shape, or if their data types do not match dataType., or if they have null-valued save slice information

  8. trait Partitioner extends AnyRef

    Permalink

    A variable partitioner is simply a function that accepts the DataType and the fully defined Shape of the variable to be created, and returns an array of integers corresponding to the number of partitions for each axis (currently only one axis can be partitioned).

  9. case class RandomNormalInitializer(mean: tensors.Tensor[types.FLOAT32] = 0.0f, standardDeviation: tensors.Tensor[types.FLOAT32] = 1.0f, seed: Option[Int] = None) extends Initializer with Product with Serializable

    Permalink

    Initializer that sets the value of the variable to a value drawn from a Normal distribution.

  10. case class RandomTruncatedNormalInitializer(mean: tensors.Tensor[types.FLOAT32] = 0.0f, standardDeviation: tensors.Tensor[types.FLOAT32] = 1.0f, seed: Option[Int] = None) extends Initializer with Product with Serializable

    Permalink

    Initializer that sets the value of the variable to a value drawn from a truncated Normal distribution.

  11. case class RandomUniformInitializer(minValue: tensors.Tensor[types.FLOAT32] = 0.0f, maxValue: tensors.Tensor[types.FLOAT32] = 1.0f, seed: Option[Int] = None) extends Initializer with Product with Serializable

    Permalink

    Initializer that sets the value of the variable to a value drawn from a uniform distribution.

  12. trait Regularizer extends AnyRef

    Permalink

    A variable regularizer is simply a function that takes an Op.Output representing the variable value as input, and returns another Output representing the regularizer value as output.

  13. sealed trait Reuse extends AnyRef

    Permalink

    Enumeration of possible variable reuse options, used by variable scopes and variable stores.

    Enumeration of possible variable reuse options, used by variable scopes and variable stores.

    The supported options are:

    • ReuseExistingOnly: Reuse existing variables only and throw an exception if no appropriate variable exists.
    • CreateNewOnly: Create new variables only and throw an exception if a variable with the same name exists.
    • ReuseOrCreateNew: Reuse existing variables or create new ones, if no variable with the provided name exists.
  14. sealed trait ReuseAllowed extends Reuse

    Permalink

    Trait marking the variable reuse modes that allow reusing existing variables.

  15. case class SaveSpecification extends Product with Serializable

    Permalink

    Class used to describe tensor slices that need to be saved.

  16. abstract class Saveable extends AnyRef

    Permalink

    Base class for defining objects that be saved and restored.

  17. class Saver extends Serializable

    Permalink

    A saver can save and restore variables and other saveable objects.

    A saver can save and restore variables and other saveable objects.

    This class adds ops to save and restore variables to and from *checkpoints*. It also provides convenience methods to run these ops. Checkpoints are binary files in a proprietary format which map variable names to tensor values. The best way to examine the contents of a checkpoint is to load it using a Saver.

    Savers can automatically number checkpoint filenames. This lets you keep multiple checkpoints at different steps while training a model. For example, you can number the checkpoint filenames with the training step number. To avoid filling up disks, savers manage checkpoint files automatically. For example, they can make sure to keep only the N most recent files, or one checkpoint for every N hours of training.

    You may number checkpoint filenames by passing a value to the optional globalStep argument of the save method. For example:

    // Using a slight abuse of notation for paths:
    saver.save(session, "my-model", globalStep = 0) ==> filename: "my-model-0"
    saver.save(session, "my-model", globalStep = 1000) ==> filename: "my-model-1000"

    Also, optional arguments to the Saver constructor let you control the proliferation of checkpoint files on disk:

    • maxToKeep: The maximum number of recent checkpoint files to keep. As new files are created, older files are deleted. If 0, no checkpoints are deleted from the filesystem but only the last one is kept in the checkpoint file. Defaults to 5 (i.e., only the 5 most recent checkpoint files are kept).
    • keepCheckpointEveryNHours: In addition to keeping the most recent maxToKeep checkpoint files, you might want to keep one checkpoint file for every N hours of training. This can be useful if you want to later analyze how a model progressed during a long training session. For example, passing keepCheckpointEveryNHours = 2 ensures that you keep one checkpoint file for every 2 hours of training. The default value of 10000 hours effectively disables the feature. Note that you still have to call the save method every time you want to save the model. Passing these arguments to the constructor will not save variables automatically for you.

    An example training program that saves regularly looks like this:

    // Using a slight abuse of notation.
    // Create a saver.
    val saver = tf.Saver(variables)
    // Launch the graph and train, saving the model every 1,000 steps.
    for (step <- 0 to 1000000) {
      session.run(trainOp)
      if (step % 1000 == 0) {
        // Append the step number to the checkpoint name.
        saver.save(session, "my-model", globalStep = step)
      }
    }

    In addition to checkpoint files, savers keep a protocol buffer on disk with the list of recent checkpoints. This is used to manage numbered checkpoint files. The latestCheckpoint method makes it easy to discover the path to the most recent checkpoint. That protocol buffer is stored in a file next to the checkpoint files, with default name "checkpoint" (can be provided using the checkpointStateFilename argument of the save method).

  18. trait SaverDefBuilder extends AnyRef

    Permalink

    A saver builder is used to build SaverDef objects.

    A saver builder is used to build SaverDef objects.

    Most users shall never have to worry about dealing with saver builders. The Saver constructor uses DefaultSaverDefBuilder by default, which should be fine for most applications.

  19. case class Variable extends Serializable with VariableLike with Product with Serializable

    Permalink

    Variable based on resource handles.

    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.

  20. trait VariableLike extends OutputConvertible

    Permalink

    Represents objects that can be used as variables (e.g., variables and partitioned variables).

  21. case class VariableScope extends Product with Serializable

    Permalink

    Variable scope that carries default settings to provide to getVariable.

    Variable scope that carries default settings to provide to getVariable.

    A variable scope allows to create new variables and to share already created ones while providing checks to not create or share by accident.

    Many of the arguments we need for getVariable in a variable store are most easily handled with a context. VariableScope objects are used for the defaults.

  22. case class VariableScopeStore extends Product with Serializable

    Permalink

    A thread-local score for the current variable scope and scope counts.

  23. case class VariableStore extends Product with Serializable

    Permalink

    Variable store that carries a number of named variables.

  24. class VarianceScalingInitializer extends Initializer

    Permalink

    Initializer capable of adapting its scale to the shape of weights tensors.

    Initializer capable of adapting its scale to the shape of weights tensors.

    With the Normal distribution option, samples are drawn from a truncated Normal distribution centered on zero, and with standard deviation equal to sqrt(initialScale / n), where n is:

    • the number of input units in the weight tensor, if mode == FanInScalingMode,
    • the number of output units, if mode == FanOutScalingMode, or
    • the average of the numbers of input and output units, if mode == FanAverageScalingMode

    With uniform distribution option, samples are drawn from a uniform distribution within [-limit, limit], where limit = sqrt(3 * initialScale / n).

Value Members

  1. object CreateNewOnly extends Reuse with Product with Serializable

    Permalink

    Create new variables only and throw an exception if a variable with the same name exists.

  2. object OnesInitializer extends Initializer

    Permalink

    Initializer that sets all elements of the variable tensor to ones.

  3. object ReuseExistingOnly extends ReuseAllowed with Product with Serializable

    Permalink

    Reuse existing variables only and throw an exception if no appropriate variable exists.

  4. object ReuseOrCreateNew extends ReuseAllowed with Product with Serializable

    Permalink

    Reuse existing variables or create new ones, if no variable with the provided name exists.

  5. object Saver

    Permalink

    Contains helper functions for managing savers.

  6. object SaverDefBuilder

    Permalink

    Contains helper functions for saver builders.

  7. object VariableScopeStore extends Serializable

    Permalink
  8. object VariableStore extends Serializable

    Permalink
  9. object VarianceScalingInitializer

    Permalink
  10. object ZerosInitializer extends Initializer

    Permalink

    Initializer that sets all elements of the variable tensor to zeros.

  11. val defaultGetter: VariableGetter

    Permalink

    This function defines the main logic of 'getVariable'.

    This function defines the main logic of 'getVariable'. However, 'underlyingGetter' may override this logic. That is why we pass it as an argument to the 'underlyingGetter'.

  12. def defaultInitializer(name: String, dataType: types.DataType = FLOAT32): Initializer

    Permalink

    Returns a default variable initializer.

    Returns a default variable initializer.

    name

    Variable name.

    dataType

    Variable data type.

    returns

    Default initializer.

    Annotations
    @throws( ... )
    Exceptions thrown

    IllegalArgumentException If no default initializer is defined for the specified data type.

Inherited from AnyRef

Inherited from Any

Ungrouped