将标量乘以 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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
