將標量乘以 Tensor 或 IndexedSlices 對象。
用法
tf.math.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.math.special.fresnel_cos用法及代碼示例
- Python tf.math.special.bessel_k0e用法及代碼示例
- Python tf.math.segment_prod用法及代碼示例
- Python tf.math.special.fresnel_sin用法及代碼示例
- Python tf.math.segment_mean用法及代碼示例
- Python tf.math.special.bessel_j1用法及代碼示例
- Python tf.math.special.bessel_j0用法及代碼示例
- Python tf.math.sinh用法及代碼示例
- Python tf.math.sign用法及代碼示例
- Python tf.math.sin用法及代碼示例
- Python tf.math.special.bessel_y0用法及代碼示例
- Python tf.math.segment_max用法及代碼示例
- Python tf.math.special.bessel_k1用法及代碼示例
- Python tf.math.softplus用法及代碼示例
- Python tf.math.special.bessel_k1e用法及代碼示例
- Python tf.math.square用法及代碼示例
- Python tf.math.subtract用法及代碼示例
- Python tf.math.special.bessel_k0用法及代碼示例
- Python tf.math.special.spence用法及代碼示例
- Python tf.math.special.dawsn用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.math.scalar_mul。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
