tf.math.multiply
| Просмотреть исходный код на GitHub |
Возвращает поэлементное произведение x * y.
tf.math.multiply(
x, y, name=None
)
Например:
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)>
| Аргументы | |
|---|---|
x | Tensor. Должен быть одного из следующих типов: bfloat16, half, float32, float64, uint8, int8, uint16, int16, int32, int64, complex64, complex128. |
y | Tensor. Должен иметь тот же тип, что и x. |
name | Имя операции (необязательно). |
| Возвращаемое значение |
|---|
Tensor. Имеет тот же тип, что и x.
| Исключения | |
|---|---|
|
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/python/tf/math/multiply