Stay organized with collections
Save and categorize content based on your preferences.
tensorflow::
ops::
Where3
#include <math_ops.h>
Selects elements from
x
or
y
, depending on
condition
.
Summary
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:
-
scope: A
Scope
object
-
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
.
Returns:
-
Output
: = A
Tensor
with the same type and shape as
x
and
y
.
Public attributes
Public functions
node
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
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 2021-08-16 UTC.
[null,null,["Last updated 2021-08-16 UTC."],[],[],null,["# tensorflow::ops::Where3 Class Reference\n\ntensorflow::\nops::\nWhere3\n=========================\n\n`\n#include \u003cmath_ops.h\u003e\n`\n\n\nSelects elements from\n`\nx\n`\nor\n`\ny\n`\n, depending on\n`\ncondition\n`\n.\n\nSummary\n-------\n\n\nThe\n`\nx\n`\n, and\n`\ny\n`\ntensors must all have the same shape, and the output will also have that shape.\n\n\nThe\n`\ncondition\n`\ntensor must be a scalar if\n`\nx\n`\nand\n`\ny\n`\nare scalars. If\n`\nx\n`\nand\n`\ny\n`\nare vectors or higher rank, then\n`\ncondition\n`\nmust be either a scalar, a vector with size matching the first dimension of\n`\nx\n`\n, or must have the same shape as\n`\nx\n`\n.\n\n\nThe\n`\ncondition\n`\ntensor 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\n`\nx\n`\n(if true) or\n`\ny\n`\n(if false).\n\n\nIf\n`\ncondition\n`\nis a vector and\n`\nx\n`\nand\n`\ny\n`\nare higher rank matrices, then it chooses which row (outer dimension) to copy from\n`\nx\n`\nand\n`\ny\n`\n. If\n`\ncondition\n`\nhas the same shape as\n`\nx\n`\nand\n`\ny\n`\n, then it chooses which element to copy from\n`\nx\n`\nand\n`\ny\n`\n.\n\n\nFor example:\n\n\n```text\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]]\nselect(condition, t, e) # =\u003e [[1, 6], [7, 4]]\n```\n\n\u003cbr /\u003e\n\n\n```text\n# 'condition' tensor is [True, False]\n# 't' is [[1, 2],\n# [3, 4]]\n# 'e' is [[5, 6],\n# [7, 8]]\nselect(condition, t, e) ==\u003e [[1, 2],\n [7, 8]]\n```\n\n\u003cbr /\u003e\n\n\n```text\n\n```\n\n\u003cbr /\u003e\n\n\nArgs:\n\n- scope: A [Scope](/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- x: = A `\n `[Tensor](/versions/r2.6/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor)`\n ` which may have the same shape as `\n condition\n ` . If `\n condition\n ` is rank 1, `\n x\n ` may have higher rank, but its first dimension must match the size of `\n condition\n ` .\n- y: = A `\n `[Tensor](/versions/r2.6/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor)`\n ` with the same type and shape as `\n x\n ` .\n\n\u003cbr /\u003e\n\n\nReturns:\n\n- `\n `[Output](/versions/r2.6/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output)`\n ` : = A `\n `[Tensor](/versions/r2.6/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor)`\n ` with the same type and shape as `\n x\n ` and `\n y\n ` .\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| ` `[Where3](#classtensorflow_1_1ops_1_1_where3_1a1e043e7f8493b555a94d106084a64a32)` (const :: `[tensorflow::Scope](/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, :: `[tensorflow::Input](/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` condition, :: `[tensorflow::Input](/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` x, :: `[tensorflow::Input](/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` y) ` ||\n\n| ### Public attributes ||\n|------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|\n| ` `[operation](#classtensorflow_1_1ops_1_1_where3_1a9b749e1046fbe4c39075a2b037391cf2)` ` | ` `[Operation](/versions/r2.6/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation)` ` |\n| ` `[output](#classtensorflow_1_1ops_1_1_where3_1a07742c7ad2705b0fa9b9cc9e59eca41b)` ` | ` :: `[tensorflow::Output](/versions/r2.6/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output)` ` |\n\n| ### Public functions ||\n|----------------------------------------------------------------------------------------------------------------------|--------------------------|\n| ` `[node](#classtensorflow_1_1ops_1_1_where3_1aacfd2a5bd041b46bc2179d3e9ac5c0c6)` () const ` | ` ::tensorflow::Node * ` |\n| ` `[operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_where3_1a7fcabeeb211b239288d028b587a88e54)` () const ` | ` ` |\n| ` `[operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_where3_1aedd6e529c7127af0c5af333ded627ab3)` () const ` | ` ` |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### output\n\n```text\n::tensorflow::Output output\n``` \n\nPublic functions\n----------------\n\n### Where3\n\n```gdscript\n Where3(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input condition,\n ::tensorflow::Input x,\n ::tensorflow::Input y\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n```"]]