tf.math.multiply
Stay organized with collections
Save and categorize content based on your preferences.
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
Args |
x
|
A Tensor. Must be one of the following types: bfloat16 ,
half , float32 , float64 , uint8 , int8 , uint16 ,
int16 , int32 , int64 , complex64 , complex128 .
|
y
|
A Tensor . Must have the same type as x .
|
name
|
A name for the operation (optional).
|
A Tensor
. Has the same type as x
.
Raises |
- InvalidArgumentError: When
x and y have incompatible shapes or types.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[]]