2017-12-11 8 views

答えて

3

最も信頼性の高いドキュメントは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_dispatchを行い__mul__演算子オーバーロードを意味します。ご覧のとおり、gen_math_ops._multf.multiplyのアンダーフードコア機能)またはテンソルが疎な場合はsparse_dense_cwise_mulのいずれかを呼び出します。

ところで、tf.scalar_mulはちょうどscalar * xsource code)以上のラッパーですので、基本的には同じですが、依存関係は逆です。

関連する問題