返回元素级 x * y。
用法
tf.math.multiply(
x, y, name=None
)参数
-
x张量。必须是以下类型之一:bfloat16,half,float32,float64,uint8,int8,uint16,int16,int32,int64,complex64,complex128。 -
y一个Tensor。必须与x具有相同的类型。 -
name操作的名称(可选)。
返回
抛出
-
- InvalidArgumentError:当
x和y具有不兼容的形状或类型时。
- InvalidArgumentError:当
例如:
x = tf.constant(([1, 2, 3, 4]))
tf.math.multiply(x, x)
<tf.Tensor:shape=(4,), dtype=..., numpy=array([ 1, 4, 9, 16], dtype=int32)>
由于 tf.math.multiply 会将其参数转换为 Tensor ,因此您也可以传入非 Tensor 参数:
tf.math.multiply(7,6)
<tf.Tensor:shape=(), dtype=int32, numpy=42>
如果 x.shape 与 y.shape 不同,它们将被广播到兼容的形状。 (更多关于广播在这里。)
例如:
x = tf.ones([1, 2]);
y = tf.ones([2, 1]);
x * y # Taking advantage of operator overriding
<tf.Tensor:shape=(2, 2), dtype=float32, numpy=
array([[1., 1.],
[1., 1.]], dtype=float32)>
此元素操作的缩减版本是tf.math.reduce_prod
一个Tensor。具有与 x 相同的类型。
相关用法
- Python tf.math.maximum用法及代码示例
- Python tf.math.minimum用法及代码示例
- Python tf.math.special.fresnel_cos用法及代码示例
- Python tf.math.polyval用法及代码示例
- Python tf.math.is_finite用法及代码示例
- Python tf.math.special.bessel_k0e用法及代码示例
- Python tf.math.acosh用法及代码示例
- Python tf.math.invert_permutation用法及代码示例
- Python tf.math.segment_prod用法及代码示例
- Python tf.math.bincount用法及代码示例
- Python tf.math.bessel_i0e用法及代码示例
- Python tf.math.unsorted_segment_min用法及代码示例
- Python tf.math.conj用法及代码示例
- Python tf.math.scalar_mul用法及代码示例
- Python tf.math.zero_fraction用法及代码示例
- Python tf.math.reduce_max用法及代码示例
- Python tf.math.special.fresnel_sin用法及代码示例
- Python tf.math.segment_mean用法及代码示例
- Python tf.math.xlog1py用法及代码示例
- Python tf.math.less_equal用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.math.multiply。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
