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