tf.raw_ops.GatherV2
bookmark_borderbookmark
Stay organized with collections
Save and categorize content based on your preferences.
Gather slices from params
axis axis
according to indices
.
View aliases
Compat aliases for migration
See
Migration guide for
more details.
tf.compat.v1.raw_ops.GatherV2
tf.raw_ops.GatherV2(
params, indices, axis, batch_dims=0, name=None
)
indices
must be an integer tensor of any dimension (usually 0-D or 1-D).
Produces an output tensor with shape params.shape[:axis] +
indices.shape[batch_dims:] + params.shape[axis + 1:]
where:
# Scalar indices (output is rank(params) - 1).
output[a_0, ..., a_n, b_0, ..., b_n] =
params[a_0, ..., a_n, indices, b_0, ..., b_n]
# Vector indices (output is rank(params)).
output[a_0, ..., a_n, i, b_0, ..., b_n] =
params[a_0, ..., a_n, indices[i], b_0, ..., b_n]
# Higher rank indices (output is rank(params) + rank(indices) - 1).
output[a_0, ..., a_n, i, ..., j, b_0, ... b_n] =
params[a_0, ..., a_n, indices[i, ..., j], b_0, ..., b_n]
Note that on CPU, if an out of bound index is found, an error is returned.
On GPU, if an out of bound index is found, a 0 is stored in the
corresponding output value.
See also tf.batch_gather
and tf.gather_nd
.
Args |
params
|
A Tensor .
The tensor from which to gather values. Must be at least rank
axis + 1 .
|
indices
|
A Tensor . Must be one of the following types: int16 , int32 , int64 .
Index tensor. Must be in range [0, params.shape[axis]) .
|
axis
|
A Tensor . Must be one of the following types: int32 , int64 .
The axis in params to gather indices from. Defaults to the first
dimension. Supports negative indexes.
|
batch_dims
|
An optional int . Defaults to 0 .
|
name
|
A name for the operation (optional).
|
Returns |
A Tensor . Has the same type as params .
|
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 2024-04-26 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 2024-04-26 UTC."],[],[],null,["# tf.raw_ops.GatherV2\n\n\u003cbr /\u003e\n\nGather slices from `params` axis `axis` according to `indices`.\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.raw_ops.GatherV2`](https://www.tensorflow.org/api_docs/python/tf/raw_ops/GatherV2)\n\n\u003cbr /\u003e\n\n tf.raw_ops.GatherV2(\n params, indices, axis, batch_dims=0, name=None\n )\n\n`indices` must be an integer tensor of any dimension (usually 0-D or 1-D).\nProduces an output tensor with shape `params.shape[:axis] +\nindices.shape[batch_dims:] + params.shape[axis + 1:]` where: \n\n # Scalar indices (output is rank(params) - 1).\n output[a_0, ..., a_n, b_0, ..., b_n] =\n params[a_0, ..., a_n, indices, b_0, ..., b_n]\n\n # Vector indices (output is rank(params)).\n output[a_0, ..., a_n, i, b_0, ..., b_n] =\n params[a_0, ..., a_n, indices[i], b_0, ..., b_n]\n\n # Higher rank indices (output is rank(params) + rank(indices) - 1).\n output[a_0, ..., a_n, i, ..., j, b_0, ... b_n] =\n params[a_0, ..., a_n, indices[i, ..., j], b_0, ..., b_n]\n\nNote that on CPU, if an out of bound index is found, an error is returned.\nOn GPU, if an out of bound index is found, a 0 is stored in the\ncorresponding output value.\n\nSee also `tf.batch_gather` and [`tf.gather_nd`](../../tf/gather_nd).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `params` | A `Tensor`. The tensor from which to gather values. Must be at least rank `axis + 1`. |\n| `indices` | A `Tensor`. Must be one of the following types: `int16`, `int32`, `int64`. Index tensor. Must be in range `[0, params.shape[axis])`. |\n| `axis` | A `Tensor`. Must be one of the following types: `int32`, `int64`. The axis in `params` to gather `indices` from. Defaults to the first dimension. Supports negative indexes. |\n| `batch_dims` | An optional `int`. Defaults to `0`. |\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| A `Tensor`. Has the same type as `params`. ||\n\n\u003cbr /\u003e"]]