tf.sparse.fill_empty_rows
Stay organized with collections
Save and categorize content based on your preferences.
Fills empty rows in the input 2-D SparseTensor
with a default value.
tf.sparse.fill_empty_rows(
sp_input, default_value, name=None
)
This op adds entries with the specified default_value
at index
[row, 0]
for any row in the input that does not already have a value.
For example, suppose sp_input
has shape [5, 6]
and non-empty values:
[0, 1]: a
[0, 3]: b
[2, 0]: c
[3, 1]: d
Rows 1 and 4 are empty, so the output will be of shape [5, 6]
with values:
[0, 1]: a
[0, 3]: b
[1, 0]: default_value
[2, 0]: c
[3, 1]: d
[4, 0]: default_value
Note that the input may have empty columns at the end, with no effect on
this op.
The output SparseTensor
will be in row-major order and will have the
same shape as the input.
This op also returns an indicator vector such that
empty_row_indicator[i] = True iff row i was an empty row.
Args |
sp_input
|
A SparseTensor with shape [N, M] .
|
default_value
|
The value to fill for empty rows, with the same type as
sp_input.
|
name
|
A name prefix for the returned tensors (optional)
|
Returns |
sp_ordered_output
|
A SparseTensor with shape [N, M] , and with all empty
rows filled in with default_value .
|
empty_row_indicator
|
A bool vector of length N indicating whether each
input row was empty.
|
Raises |
TypeError
|
If sp_input is not a SparseTensor .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[],null,["# tf.sparse.fill_empty_rows\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/sparse/fill_empty_rows) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/ops/sparse_ops.py#L1856-L1920) |\n\nFills empty rows in the input 2-D `SparseTensor` with a default value.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.sparse.fill_empty_rows`](/api_docs/python/tf/sparse/fill_empty_rows), [`tf.compat.v1.sparse_fill_empty_rows`](/api_docs/python/tf/sparse/fill_empty_rows)\n\n\u003cbr /\u003e\n\n tf.sparse.fill_empty_rows(\n sp_input, default_value, name=None\n )\n\nThis op adds entries with the specified `default_value` at index\n`[row, 0]` for any row in the input that does not already have a value.\n\nFor example, suppose `sp_input` has shape `[5, 6]` and non-empty values: \n\n [0, 1]: a\n [0, 3]: b\n [2, 0]: c\n [3, 1]: d\n\nRows 1 and 4 are empty, so the output will be of shape `[5, 6]` with values: \n\n [0, 1]: a\n [0, 3]: b\n [1, 0]: default_value\n [2, 0]: c\n [3, 1]: d\n [4, 0]: default_value\n\nNote that the input may have empty columns at the end, with no effect on\nthis op.\n\nThe output `SparseTensor` will be in row-major order and will have the\nsame shape as the input.\n\nThis op also returns an indicator vector such that \n\n empty_row_indicator[i] = True iff row i was an empty row.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|---------------------------------------------------------------------|\n| `sp_input` | A `SparseTensor` with shape `[N, M]`. |\n| `default_value` | The value to fill for empty rows, with the same type as `sp_input.` |\n| `name` | A name prefix for the returned tensors (optional) |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|-----------------------|-----------------------------------------------------------------------------------------------|\n| `sp_ordered_output` | A `SparseTensor` with shape `[N, M]`, and with all empty rows filled in with `default_value`. |\n| `empty_row_indicator` | A bool vector of length `N` indicating whether each input row was empty. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|----------------------------------------|\n| `TypeError` | If `sp_input` is not a `SparseTensor`. |\n\n\u003cbr /\u003e"]]