View source on GitHub |
Returns an element-wise x * y.
tf.math.multiply(
x, y, name=None
)
Used in the notebooks
Used in the guide | Used in the tutorials |
---|---|
For example:
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)>
Since tf.math.multiply
will convert its arguments to Tensor
s, you can also
pass in non-Tensor
arguments:
tf.math.multiply(7,6)
<tf.Tensor: shape=(), dtype=int32, numpy=42>
If x.shape
is not the same as y.shape
, they will be broadcast to a
compatible shape. (More about broadcasting
here.)
For example:
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)>
The reduction version of this elementwise operation is tf.math.reduce_prod
Returns |
---|
A Tensor
. Has the same type as x
.
Raises | |
---|---|
|