tf.raw_ops.Select
bookmark_borderbookmark
Stay organized with collections
Save and categorize content based on your preferences.
Selects elements from x
or y
, depending on condition
.
View aliases
Compat aliases for migration
See
Migration guide for
more details.
tf.compat.v1.raw_ops.Select
tf.raw_ops.Select(
condition, x, y, name=None
)
The x
, and y
tensors must all have the same shape, and the
output will also have that shape.
The condition
tensor must be a scalar if x
and y
are scalars.
If x
and y
are vectors or higher rank, then condition
must be either a
scalar, a vector with size matching the first dimension of x
, or must have
the same shape as x
.
The condition
tensor acts as a mask that chooses, based on the value at each
element, whether the corresponding element / row in the output should be
taken from x
(if true) or y
(if false).
If condition
is a vector and x
and y
are higher rank matrices, then
it chooses which row (outer dimension) to copy from x
and y
.
If condition
has the same shape as x
and y
, then it chooses which
element to copy from x
and y
.
For example:
# 'condition' tensor is [[True, False]
# [False, True]]
# 't' is [[1, 2],
# [3, 4]]
# 'e' is [[5, 6],
# [7, 8]]
select(condition, t, e) # => [[1, 6], [7, 4]]
# 'condition' tensor is [True, False]
# 't' is [[1, 2],
# [3, 4]]
# 'e' is [[5, 6],
# [7, 8]]
select(condition, t, e) ==> [[1, 2],
[7, 8]]
Args |
condition
|
A Tensor of type bool .
|
x
|
A Tensor which may have the same shape as condition .
If condition is rank 1, x may have higher rank,
but its first dimension must match the size of condition .
|
y
|
A Tensor with the same type and shape as x .
|
name
|
A name for the operation (optional).
|
Returns |
A Tensor . Has the same type as t .
|
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.Select\n\n\u003cbr /\u003e\n\nSelects elements from `x` or `y`, depending on `condition`.\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.Select`](https://www.tensorflow.org/api_docs/python/tf/raw_ops/Select)\n\n\u003cbr /\u003e\n\n tf.raw_ops.Select(\n condition, x, y, name=None\n )\n\nThe `x`, and `y` tensors must all have the same shape, and the\noutput will also have that shape.\n\nThe `condition` tensor must be a scalar if `x` and `y` are scalars.\nIf `x` and `y` are vectors or higher rank, then `condition` must be either a\nscalar, a vector with size matching the first dimension of `x`, or must have\nthe same shape as `x`.\n\nThe `condition` tensor acts as a mask that chooses, based on the value at each\nelement, whether the corresponding element / row in the output should be\ntaken from `x` (if true) or `y` (if false).\n\nIf `condition` is a vector and `x` and `y` are higher rank matrices, then\nit chooses which row (outer dimension) to copy from `x` and `y`.\nIf `condition` has the same shape as `x` and `y`, then it chooses which\nelement to copy from `x` and `y`.\n\n#### For example:\n\n # 'condition' tensor is [[True, False]\n # [False, True]]\n # 't' is [[1, 2],\n # [3, 4]]\n # 'e' is [[5, 6],\n # [7, 8]]\n select(condition, t, e) # =\u003e [[1, 6], [7, 4]]\n\n\n # 'condition' tensor is [True, False]\n # 't' is [[1, 2],\n # [3, 4]]\n # 'e' is [[5, 6],\n # [7, 8]]\n select(condition, t, e) ==\u003e [[1, 2],\n [7, 8]]\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `condition` | A `Tensor` of type `bool`. |\n| `x` | A `Tensor` which may have the same shape as `condition`. If `condition` is rank 1, `x` may have higher rank, but its first dimension must match the size of `condition`. |\n| `y` | A `Tensor` with the same type and shape as `x`. |\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 `t`. ||\n\n\u003cbr /\u003e"]]