從 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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
