tf.compat.v1.scalar_mul
Умножает скаляр на объект типа Tensor или IndexedSlices.
tf.compat.v1.scalar_mul(
scalar, x, name=None
)
Это частный случай tf.math.multiply, где первое значение должно быть скаляром. В отличие от общего случая tf.math.multiply, эта операция гарантированно эффективна для tf.IndexedSlices.
x = tf.reshape(tf.range(30, dtype=tf.float32), [10, 3]) with tf.GradientTape() as g: g.watch(x) y = tf.gather(x, [1, 2]) # IndexedSlices z = tf.math.scalar_mul(10.0, y)
| Аргументы | |
|---|---|
scalar | Скаляр 0-мерного ранга Tensor. Должен иметь известную форму. |
x | Объект типа Tensor или IndexedSlices, который необходимо масштабировать. |
name | Имя операции (необязательно). |
| Возвращаемое значение | |
|---|---|
Результат умножения, имеющий тот же тип (Tensor или IndexedSlices) что и x. |
| Исключения | |
|---|---|
ValueError | если скаляр не является 0-мерным scalar. |
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/compat/v1/scalar_mul