SparseToDense
tensorflow C++ API
tensorflow::ops::SparseToDense
Converts a sparse representation into a dense tensor.
Summary
Builds an arraydense
with shapeoutput_shape
such that
``` If sparse_indices is scalar
dense[i] = (i == sparse_indices ? sparse_values : default_value)
If sparse_indices is a vector, then for each i
dense[sparse_indices[i]] = sparse_values[i]
If sparse_indices is an n by d matrix, then for each i in [0, n)
dense[sparse_indices[i][0], …, sparse_indices[i][d-1]] = sparse_values[i] ```
Allother values indense
are set todefault_value
. Ifsparse_values
is a scalar, all sparse indices are set to this single value.
Indices should be sorted in lexicographic order, and indices must not contain any repeats. Ifvalidate_indices
is true, these properties are checked during execution.
Arguments:
- scope: AScope object
- sparse_indices: 0-D, 1-D, or 2-D.
sparse_indices[i]
contains the complete index wheresparse_values[i]
will be placed. - output_shape: 1-D.Shapeof the dense output tensor.
- sparse_values: 1-D. Values corresponding to each row of
sparse_indices
, or a scalar value to be used for all sparse indices. - default_value: Scalar value to set for indices not specified in
sparse_indices
.
Optional attributes (seeAttrs
):
- validate_indices: If true, indices are checked to make sure they are sorted in lexicographic order and that there are no repeats.
Returns:
Output
: Dense output tensor of shapeoutput_shape
.
SparseToDense block
Source link : https://github.com/EXPNUNI/enuSpaceTensorflow/blob/master/enuSpaceTensorflow/tf_sparse.cpp
Argument:
- Scope scope : A Scope object (A scope is generated automatically each page. A scope is not connected.)
- Input sparse_indices: connect Input node.
- Input output_shape: connect Input node.
- Input sparse_values: connect Input node.
- Input default_value: connect Input node.
- SparseToDense::Attrs attrs : Input attrs in value. ex) validate_indices_ = true;
Return:
- Output output: Output object of SparseToDense class object.
Result:
- std::vector(Tensor) result_output : Returned object of executed result by calling session.