2024-04-28 01:49:53 发布
网友
我找不到*的文档。它似乎可以等价于tf.multiply或{}。是这样吗?在
*
tf.multiply
最可靠的文档是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")
这意味着__mul__运算符重载,它执行_mul_dispatch。如您所见,它调用gen_math_ops._mul(这是^{}的底层核心函数)或者{},如果张量是稀疏的。在
__mul__
_mul_dispatch
gen_math_ops._mul
顺便说一句,tf.scalar_mul只是scalar * x(source code)上的包装,所以基本上是一样的,但是依赖关系是相反的。在
tf.scalar_mul
scalar * x
最可靠的文档是source code:
这意味着} 的底层核心函数)或者{},如果张量是稀疏的。在
__mul__
运算符重载,它执行_mul_dispatch
。如您所见,它调用gen_math_ops._mul
(这是^{顺便说一句,
tf.scalar_mul
只是scalar * x
(source code)上的包装,所以基本上是一样的,但是依赖关系是相反的。在相关问题 更多 >
编程相关推荐