Link Search Menu Expand Document

SparseFillEmptyRows


tensorflow C++ API

tensorflow::ops::SparseFillEmptyRows

Fills empty rows in the input 2-DSparseTensorwith a default value.


Summary

The inputSparseTensoris represented via the tuple of inputs (indices,values,dense_shape). The outputSparseTensorhas the samedense_shapebut with indicesoutput_indicesand valuesoutput_values.

This op inserts a single entry for every row that doesn’t have any values. The index is created as[row, 0, ..., 0]and the inserted value isdefault_value.

For example, supposesp_inputhas shape[5, 6]and non-empty values:


Rows 1 and 4 are empty, so the output will be of shape[5, 6]with values:


The outputSparseTensorwill be in row-major order and will have the same shape as the input.

This op also returns an indicator vector shaped[dense_shape[0]]such that

empty_row_indicator[i]=True iff row i was an empty row.

And a reverse index map vector shaped[indices.shape[0]]that is used during backpropagation,

reverse_index_map[j]= out_j s.t. indices[j,:]== output_indices[out_j,:]

Arguments:

  • scope: A Scope object
  • indices: 2-D. the indices of the sparse tensor.
  • values: 1-D. the values of the sparse tensor.
  • dense_shape: 1-D. the shape of the sparse tensor.
  • default_value: 0-D. default value to insert into location[row, 0, ..., 0] for rows missing from the input sparse tensor. output indices: 2-D. the indices of the filled sparse tensor.

Returns:

  • Outputoutput_indices
  • Outputoutput_values: 1-D. the values of the filled sparse tensor.
  • Outputempty_row_indicator: 1-D. whether the dense row was missing in the input sparse tensor.
  • Outputreverse_index_map: 1-D. a map from the input indices to the output indices.

SparseFillEmptyRows 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 indices: connect Input node.
  • Input values: connect Input node.
  • Input dense_shape: connect Input node.
  • Input default_value: connect Input node.

Return:

  • Output output_indices: Output object of SparseFillEmptyRows class object.
  • Output output_values: Output object of SparseFillEmptyRows class object.
  • Output empty_row_indicator: Output object of SparseFillEmptyRows class object.
  • Output reverse_index_map: Output object of SparseFillEmptyRows class object.

Result:

  • std::vector(Tensor) result_output_indices : Returned object of executed result by calling session.
  • std::vector(Tensor) result_output_values : Returned object of executed result by calling session.
  • std::vector(Tensor) result_empty_row_indicator : Returned object of executed result by calling session.
  • std::vector(Tensor) result_reverse_index_map : Returned object of executed result by calling session.

Using Method