Consumers of these indexed slices (i.e., ops that use this op output as one of their inputs).
Consumers of these indexed slices (i.e., ops that use this op output as one of their inputs).
Data type of this sparse op output.
Data type of this sparse op output.
Device on which this sparse op output will be placed.
Device on which this sparse op output will be placed.
Graph that contains values
, indices
, and denseShape
.
Graph that contains values
, indices
, and denseShape
.
Name of this sparse op output.
Name of this sparse op output.
Op that outputs this sparse tensor.
Op that outputs this sparse tensor.
Gets the Shape corresponding to the shape of the dense tensor that this sparse tensor represents.
Gets the Shape corresponding to the shape of the dense tensor that this sparse tensor represents.
Dense tensor shape.
Converts this sparse tensor to a dense tensor.
Converts this sparse tensor to a dense tensor.
The constructed op builds a tensor dense
with shape input.denseShape
, such that:
// If input.indices is scalar: dense(i) ==> (i == input.indices ? input.values : defaultValue) // If input.indices is a vector, then for each i: dense(input.indices(i)) ==> input.values(i) // If input.indices is an n by d matrix, then for each i in [0, n): dense(input.indices(i)(0), ..., input.indices(i)(d-1)) ==> input.values(i)
All other values in dense
are set to defaultValue
. If input.values
is a scalar, then all sparse indices
are set to that single value.
input.indices
should be sorted in lexicographic order and they must not contain any repeats. If
validateIndices
is true
, then these properties are checked during execution.
Scalar tensor with the same data type as input.values
, containing the value set for
indices that are not specified in input.indices
.
If true
, the indices in input.indices
are checked to make sure that they are sorted in
lexicographic order and that there are no repeats.
Name for the created op.
Created op output, with the same data type as input.values
and shape input.denseShape
.
Returns the Output that this OutputLike object represents.
Returns the Output that this OutputLike object represents.
Returns an OutputIndexedSlices that has the same value as this OutputLike.
Returns an OutputIndexedSlices that has the same value as this OutputLike.
Boolean flag indicating whether to optimize this conversion by using a constant op with the shape of this tensor at graph creation time (instead of execution time), if known.
OutputIndexedSlices that has the same value as this OutputLike.
One-dimensional tensor with shape [N]
.
Represents a sparse op output.
TensorFlow represents a sparse tensor as three separate dense tensors:
indices
,values
, anddenseShape
. In Scala, the three tensors are collected into a SparseOutput class for ease of use. If you have separateindices
,values
, anddenseShape
tensors, wrap them in aSparseTensor
object before passing to the relevant sparse tensor manipulation.Concretely, the sparse tensor
SparseOutput(indices, values, denseShape)
comprises the following components, whereN
andrank
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 inindices
. For example, givenindices = 3], [2, 4
, the parametervalues = [18, 3.6]
specifies that element[1, 3]
of the sparse tensor has a value of18
, and element[2, 4]
of the tensor has a value of3.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, anddenseShape = [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 onindices(i)
). This is not enforced whenSparseTensor
objects are constructed, but most ops assume correct ordering. If the ordering of sparse tensorst
is wrong, a fixed version can be obtained by callingsparseReorder(st)
.For example, the sparse tensor
SparseOutput(indices = 0], [1, 2, values = [1, 2], denseShape = [3, 4])
, represents the dense tensor0, 0, 0], [0, 0, 2, 0], [0, 0, 0, 0
.Two-dimensional INT32 or INT64 tensor with shape
[N, rank]
.One-dimensional tensor with shape
[N]
.One-dimensional INT32 or INT64 tensor with shape
[rank]
.