W3cubDocs

/TensorFlow C++

tensorflow::ops::SparseToDense

#include <sparse_ops.h>

Converts a sparse representation into a dense tensor.

Summary

Builds an array dense with shape output_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] ```

All other values in dense are set to default_value. If sparse_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. If validate_indices is true, these properties are checked during execution.

Arguments:

  • scope: A Scope object
  • sparse_indices: 0-D, 1-D, or 2-D. sparse_indices[i] contains the complete index where sparse_values[i] will be placed.
  • output_shape: 1-D. Shape of 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 (see Attrs):

  • 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 shape output_shape.
Constructors and Destructors
SparseToDense(const ::tensorflow::Scope & scope, ::tensorflow::Input sparse_indices, ::tensorflow::Input output_shape, ::tensorflow::Input sparse_values, ::tensorflow::Input default_value)
SparseToDense(const ::tensorflow::Scope & scope, ::tensorflow::Input sparse_indices, ::tensorflow::Input output_shape, ::tensorflow::Input sparse_values, ::tensorflow::Input default_value, const SparseToDense::Attrs & attrs)
Public attributes
dense
Public functions
node() const
::tensorflow::Node *
operator::tensorflow::Input() const
operator::tensorflow::Output() const
Public static functions
ValidateIndices(bool x)
Structs
tensorflow::ops::SparseToDense::Attrs

Optional attribute setters for SparseToDense.

Public attributes

dense

::tensorflow::Output dense

Public functions

SparseToDense

 SparseToDense(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input sparse_indices,
  ::tensorflow::Input output_shape,
  ::tensorflow::Input sparse_values,
  ::tensorflow::Input default_value
)

SparseToDense

 SparseToDense(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input sparse_indices,
  ::tensorflow::Input output_shape,
  ::tensorflow::Input sparse_values,
  ::tensorflow::Input default_value,
  const SparseToDense::Attrs & attrs
)

node

::tensorflow::Node * node() const 

operator::tensorflow::Input

operator::tensorflow::Input() const 

operator::tensorflow::Output

operator::tensorflow::Output() const 

Public static functions

ValidateIndices

Attrs ValidateIndices(
  bool x
)

© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/sparse-to-dense.html