用法
__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__。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
