I don't find where *
is documented. It seems that it can be equivalent to either tf.multiply
or tf.scalar_mul
. Is it so?
The TensorFlow Core APIs provide a set of comprehensive, composable, and extensible low-level APIs for high-performance (distributed & accelerated) computation, primarily aimed at building machine learning (ML) models as well as authoring ML workflow tools and frameworks within the TensorFlow platform.
TensorFlow can be used in a wide variety of programming languages, including Python, JavaScript, C++, and Java. This flexibility lends itself to a range of applications in many different sectors.
TensorFlow is an end-to-end open source platform for machine learning. TensorFlow makes it easy for beginners and experts to create machine learning models.
tf. constant is useful for asserting that the value can be embedded that way. If the argument dtype is not specified, then the type is inferred from the type of value . # Constant 1-D Tensor from a python list. tf.
The most reliable documentation is the source code:
def _mul_dispatch(x, y, name=None):
"""Dispatches cwise mul for "Dense*Dense" and "Dense*Sparse"."""
is_tensor_y = isinstance(y, ops.Tensor)
if is_tensor_y:
return gen_math_ops._mul(x, y, name=name)
else:
assert isinstance(y, sparse_tensor.SparseTensor) # Case: Dense * Sparse.
new_vals = gen_sparse_ops.sparse_dense_cwise_mul(y.indices, y.values,
y.dense_shape, x, name)
return sparse_tensor.SparseTensor(y.indices, new_vals, y.dense_shape)
...
_OverrideBinaryOperatorHelper(_mul_dispatch, "mul")
This means __mul__
operator overload, which does _mul_dispatch
. As you can see, it calls either gen_math_ops._mul
(which is the under-the-hood core function of tf.multiply
) or sparse_dense_cwise_mul
if the tensor is sparse.
By the way, tf.scalar_mul
is just a wrapper over scalar * x
(source code), so it's basically the same thing, but the dependency is the other way around.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With