Trait for specifying supported embedding parameter types.
Graph extension helper for constructing a function.
Graph extension helper for constructing a function.
A FunctionGraph keeps track of all inputs into every op created inside it. If any input is from another graph, we keep track of it and substitute the input with a placeholder.
Each captured input's corresponding placeholder is converted into a function argument and the caller passes in the captured tensor.
Wrapper around an Op meant to represent one of its inputs.
Represents a graph node, or as we shall call it, an operation, that performs computation on tensors.
Represents a graph node, or as we shall call it, an operation, that performs computation on tensors.
TODO: Add Op.run method and Op.Output.eval method.
An Op
is a symbolic representation of the computation it performs. It is a node in a TensorFlow Graph that
takes zero or more Op.Output
objects as input, and produces zero or more Op.Output
objects as output. Op
objects are constructed by calling op creation functions, such as Basic.constant or Math.matmul.
For example, val c = MathOps.matmul(a, b)
creates an Op
of type "MatMul"
that takes Op.Output
s a
and
b
as input, and produces Op.Output
c
as output.
The Op.Input
class is simply a wrapper around an Op
meant to represent one of its inputs. Actual op inputs
have type Op.Output
since they represent outputs of other ops. Currently, Op.Input
is only useful for
representing consumers of an Op
's outputs.
After the graph has been launched in a Session, an Op
can be executed by using Session.run
.
TODO: Add Op.run
use example, once that is supported.
Representation of one of the outputs of an Op's computation.
Representation of one of the outputs of an Op's computation.
An Output
is a symbolic handle to one of the outputs of an Op. It does not hold the values of that op's
output, but instead provides a means of computing those values in a TensorFlow Session.
This class has two primary purposes:
Output.evaluate
can also be used to compute the value of an Output If no session is provided,
then the default session is used.In the following example, c
, d
, and e
are symbolic Output objects, whereas result
is a Scala array
that stores a concrete value:
val c = constant(Array(Array(1.0, 2.0), Array(3.0, 4.0))) val d = constant(Array(Array(1.0, 1.0), Array(0.0, 1.0))) val e = matmul(c, d) val result = e.evaluate() // 'result' now holds the result of the matrix multiplication.
Helper tagging trait used to group Output
s, OutputIndexedSlice
s, SparseOutput
s, and TensorArray
s under the
same type.
Helper tagging trait used to group Output
s, OutputIndexedSlice
s, SparseOutput
s, and TensorArray
s under the
same type. It is useful for the while loop variable map function which is used in the seq2seq
package.
Sparse representation of a set of tensor slices at given indices.
Sparse representation of a set of tensor slices at given indices.
This class if a simple wrapper for a pair (or a set of three) of Output objects:
indices
: A one-dimensional integer Output with shape [D0]
.values
: An Output of any data type, with shape [D0, D1, ..., Dn]
.denseShape
: Optionally, an integer Output with shape [LARGE0, D1, ..., Dn]
.An OutputIndexedSlices is typically used to represent a subset of a larger Output, dense
, of shape
[LARGE0, D1, ..., Dn]
, where LARGE0 >> D0
. The values in indices
are the indices in the first dimension of
the slices that have been extracted from the larger tensor.
The dense Output, dense
, represented by OutputIndexedSlices, slices
, has:
dense(slices.indices(i), ::, ::, ...) = slices.values(i, ::, ::, ...)
The OutputIndexedSlices class is used primarily in the definition of gradients for operations that have
sparse gradients, such as gather
.
Note that this is different than SparseOutput which uses multi-dimensional indices and scalar values.
Trait representing outputs of an Op's computation.
Contains functions for constructing ops related to parsing data.
Class that supports all TensorFlow queue implementations.
Class that supports all TensorFlow queue implementations.
A queue is a TensorFlow data structure that stores tensors across multiple steps, and exposes operations that enqueue and dequeue tensors.
Each queue element is a sequence/tuple of one or more tensors, where each tuple component has a static data type, and may have a statically-known shape. The queue implementations support versions of enqueue and dequeue that handle single elements and versions that support enqueuing and dequeuing many elements at once.
Represents a TensorFlow resource.
Represents a TensorFlow resource.
Handle to the resource.
Op that initializes the resource.
BOOLEAN scalar tensor denoting whether this resource has been initialized.
Type trait specifying the supported types for set operation inputs.
Represents a sparse op output.
Represents a sparse op output.
TensorFlow represents a sparse tensor as three separate dense tensors: indices
, values
, and denseShape
. In
Scala, the three tensors are collected into a SparseOutput class for ease of use. If you have separate
indices
, values
, and denseShape
tensors, wrap them in a SparseTensor
object before passing to the
relevant sparse tensor manipulation.
Concretely, the sparse tensor SparseOutput(indices, values, denseShape)
comprises the following components,
where N
and rank
are the number of values and number of dimensions in the SparseOutput, respectively:
indices
: Two-dimensional INT64 tensor with shape [N, rank]
, which specifies the indices of the elements
in the sparse tensor that have nonzero values (elements are zero-indexed). For example,
indices = 3], [2, 4
specifies that the elements with indexes [1, 3]
and [2, 4]
have nonzero
values.values
: One-dimensional tensor of any type, with shape [N]
, which supplies the values for each element in
indices
. For example, given indices = 3], [2, 4
, the parameter values = [18, 3.6]
specifies that
element [1, 3]
of the sparse tensor has a value of 18
, and element [2, 4]
of the tensor has a value of
3.6
.denseShape
: One-dimensional INT64 tensor with shape [rank]
, which specifies the dense shape of the
sparse tensor. For example, denseShape = [3, 6]
specifies a two-dimensional 3x6 tensor,
denseShape = [2, 3, 4]
specifies a three-dimensional 2x3x4 tensor, and denseShape = [9]
specifies a
one-dimensional tensor with 9 elements.The corresponding dense tensor, dense
, satisfies:
dense.shape == denseShape
dense(indices(i)) = values(i) // Using a somewhat loose notation with respect to indexing.
IMPORTANT NOTE: By convention, indices
should be sorted in row-major order (or equivalently lexicographic order
on indices(i)
). This is not enforced when SparseTensor
objects are constructed, but most ops assume correct
ordering. If the ordering of sparse tensor st
is wrong, a fixed version can be obtained by calling
sparseReorder(st)
.
For example, the sparse tensor SparseOutput(indices = 0], [1, 2, values = [1, 2], denseShape = [3, 4])
,
represents the dense tensor 0, 0, 0], [0, 0, 2, 0], [0, 0, 0, 0
.
Class wrapping dynamic-sized, per-time-step, write-once tensor arrays.
Class wrapping dynamic-sized, per-time-step, write-once tensor arrays.
This class is meant to be used with dynamic iteration primitives such as whileLoop
and mapFunction
. It supports
gradient back-propagation via special "flow" control flow dependencies.
Note that the name of the TensorArray
(even if passed in) is uniquified automatically. Each time a new
TensorArray
is created at runtime it is assigned its own name for the duration of the run. This avoids name
collisions if a TensorArray
is created within a whileLoop
.
Contains helper functions for dealing with function graphs.
Contains helper functions and classes for creating IO-related ops.