tf.sparse.mask
bookmark_borderbookmark
Stay organized with collections
Save and categorize content based on your preferences.
Masks elements of IndexedSlices
.
View aliases
Compat aliases for migration
See
Migration guide for
more details.
tf.compat.v1.sparse.mask
, tf.compat.v1.sparse_mask
tf.sparse.mask(
a, mask_indices, name=None
)
Given an IndexedSlices
instance a
, returns another IndexedSlices
that
contains a subset of the slices of a
. Only the slices at indices not
specified in mask_indices
are returned.
This is useful when you need to extract a subset of slices in an
IndexedSlices
object.
For example:
# `a` contains slices at indices [12, 26, 37, 45] from a large tensor
# with shape [1000, 10]
a.indices # [12, 26, 37, 45]
tf.shape(a.values) # [4, 10]
# `b` will be the subset of `a` slices at its second and third indices, so
# we want to mask its first and last indices (which are at absolute
# indices 12, 45)
b = tf.sparse.mask(a, [12, 45])
b.indices # [26, 37]
tf.shape(b.values) # [2, 10]
Args |
a
|
An IndexedSlices instance.
|
mask_indices
|
Indices of elements to mask.
|
name
|
A name for the operation (optional).
|
Returns |
The masked IndexedSlices instance.
|
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. Some content is licensed under the numpy license.
Last updated 2022-11-04 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 2022-11-04 UTC."],[],[],null,["# tf.sparse.mask\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.7.4/tensorflow/python/ops/array_ops.py#L1926-L1967) |\n\nMasks elements of `IndexedSlices`.\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.mask`](https://www.tensorflow.org/api_docs/python/tf/sparse/mask), [`tf.compat.v1.sparse_mask`](https://www.tensorflow.org/api_docs/python/tf/sparse/mask)\n\n\u003cbr /\u003e\n\n tf.sparse.mask(\n a, mask_indices, name=None\n )\n\nGiven an `IndexedSlices` instance `a`, returns another `IndexedSlices` that\ncontains a subset of the slices of `a`. Only the slices at indices not\nspecified in `mask_indices` are returned.\n\nThis is useful when you need to extract a subset of slices in an\n`IndexedSlices` object.\n\n#### For example:\n\n # `a` contains slices at indices [12, 26, 37, 45] from a large tensor\n # with shape [1000, 10]\n a.indices # [12, 26, 37, 45]\n tf.shape(a.values) # [4, 10]\n\n # `b` will be the subset of `a` slices at its second and third indices, so\n # we want to mask its first and last indices (which are at absolute\n # indices 12, 45)\n b = tf.sparse.mask(a, [12, 45])\n\n b.indices # [26, 37]\n tf.shape(b.values) # [2, 10]\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------|--------------------------------------|\n| `a` | An `IndexedSlices` instance. |\n| `mask_indices` | Indices of elements to mask. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| The masked `IndexedSlices` instance. ||\n\n\u003cbr /\u003e"]]