从 x 或 y 中选择元素,具体取决于 condition 。
用法
tf.raw_ops.Select(
condition, x, y, name=None
)参数
-
conditionTensor类型为bool。 -
xTensor可能与condition具有相同的形状。如果condition是 rank 1,则x可能有更高的 rank,但它的第一个维度必须与condition的大小匹配。 -
y与x具有相同类型和形状的Tensor。 -
name操作的名称(可选)。
返回
-
一个
Tensor。具有与t相同的类型。
x 和 y 张量必须具有相同的形状,并且输出也将具有该形状。
如果 x 和 y 是标量,则 condition 张量必须是标量。如果 x 和 y 是向量或更高等级,则 condition 必须是标量,大小与 x 的第一个维度匹配的向量,或者必须具有与 x 相同的形状。
condition 张量充当掩码,根据每个元素的值选择输出中的相应元素/行是否应取自 x(如果为真)或 y(如果为假)。
如果 condition 是一个向量并且 x 和 y 是更高等级的矩阵,那么它选择从 x 和 y 复制哪一行(外部维度)。如果 condition 与 x 和 y 具有相同的形状,则它选择从 x 和 y 复制哪个元素。
例如:
# '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]]
相关用法
- Python tf.raw_ops.SelfAdjointEigV2用法及代码示例
- Python tf.raw_ops.SegmentMean用法及代码示例
- Python tf.raw_ops.SegmentMin用法及代码示例
- Python tf.raw_ops.SegmentSum用法及代码示例
- Python tf.raw_ops.SegmentMax用法及代码示例
- Python tf.raw_ops.SegmentProd用法及代码示例
- Python tf.raw_ops.Size用法及代码示例
- Python tf.raw_ops.ScatterUpdate用法及代码示例
- Python tf.raw_ops.ScatterNdUpdate用法及代码示例
- Python tf.raw_ops.SparseCrossV2用法及代码示例
- Python tf.raw_ops.ScatterAdd用法及代码示例
- Python tf.raw_ops.Sub用法及代码示例
- Python tf.raw_ops.SparseCross用法及代码示例
- Python tf.raw_ops.ScatterSub用法及代码示例
- Python tf.raw_ops.StringStrip用法及代码示例
- Python tf.raw_ops.SparseConcat用法及代码示例
- Python tf.raw_ops.SparseSegmentSumWithNumSegments用法及代码示例
- Python tf.raw_ops.SparseMatrixSparseMatMul用法及代码示例
- Python tf.raw_ops.SparseMatrixOrderingAMD用法及代码示例
- Python tf.raw_ops.Shape用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.raw_ops.Select。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
