將標量乘以 Tensor 或 IndexedSlices 對象。
用法
tf.compat.v1.scalar_mul(
scalar, x, name=None
)參數
-
scalar一個 0-D 標量Tensor。必須有已知的形狀。 -
x要縮放的Tensor或IndexedSlices。 -
name操作的名稱(可選)。
返回
-
scalar * x與x的類型相同(Tensor或IndexedSlices)。
拋出
-
ValueError如果標量不是 0-Dscalar。
這是 tf.math.multiply 的特殊情況,其中第一個值必須是 scalar 。與 tf.math.multiply 的一般形式不同,這是保證對 tf.IndexedSlices 有效的操作。
x = tf.reshape(tf.range(30, dtype=tf.float32), [10, 3])
with tf.GradientTape() as g:
g.watch(x)
y = tf.gather(x, [1, 2]) # IndexedSlices
z = tf.math.scalar_mul(10.0, y)
相關用法
- Python tf.compat.v1.scatter_min用法及代碼示例
- Python tf.compat.v1.scatter_add用法及代碼示例
- Python tf.compat.v1.scatter_div用法及代碼示例
- Python tf.compat.v1.scatter_update用法及代碼示例
- Python tf.compat.v1.scatter_nd_sub用法及代碼示例
- Python tf.compat.v1.scatter_mul用法及代碼示例
- Python tf.compat.v1.scan用法及代碼示例
- Python tf.compat.v1.scatter_sub用法及代碼示例
- Python tf.compat.v1.scatter_nd_update用法及代碼示例
- Python tf.compat.v1.scatter_nd_add用法及代碼示例
- Python tf.compat.v1.scatter_max用法及代碼示例
- Python tf.compat.v1.strings.length用法及代碼示例
- Python tf.compat.v1.summary.merge用法及代碼示例
- Python tf.compat.v1.size用法及代碼示例
- Python tf.compat.v1.summary.FileWriter用法及代碼示例
- Python tf.compat.v1.space_to_batch用法及代碼示例
- Python tf.compat.v1.string_split用法及代碼示例
- Python tf.compat.v1.squeeze用法及代碼示例
- Python tf.compat.v1.set_random_seed用法及代碼示例
- Python tf.compat.v1.sparse_to_dense用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.v1.scalar_mul。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
