用法
__mul__(
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 * y。
例如:
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.RaggedTensor.__rmul__用法及代码示例
- Python tf.RaggedTensor.__radd__用法及代码示例
- Python tf.RaggedTensor.__pow__用法及代码示例
- Python tf.RaggedTensor.__rand__用法及代码示例
- Python tf.RaggedTensor.__xor__用法及代码示例
- Python tf.RaggedTensor.__gt__用法及代码示例
- Python tf.RaggedTensor.__getitem__用法及代码示例
- Python tf.RaggedTensor.__rpow__用法及代码示例
- Python tf.RaggedTensor.__rxor__用法及代码示例
- Python tf.RaggedTensor.__ror__用法及代码示例
- Python tf.RaggedTensor.__rsub__用法及代码示例
- Python tf.RaggedTensor.__abs__用法及代码示例
- Python tf.RaggedTensor.__sub__用法及代码示例
- Python tf.RaggedTensor.__add__用法及代码示例
- Python tf.RaggedTensor.__lt__用法及代码示例
- Python tf.RaggedTensor.__or__用法及代码示例
- Python tf.RaggedTensor.__ge__用法及代码示例
- Python tf.RaggedTensor.__invert__用法及代码示例
- Python tf.RaggedTensor.__le__用法及代码示例
- Python tf.RaggedTensor.__and__用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.RaggedTensor.__mul__。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
