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