How does tensorflow batch_matmul work?

前端 未结 6 1073
迷失自我
迷失自我 2020-12-31 10:34

Tensorflow has a function called batch_matmul which multiplies higher dimensional tensors. But I\'m having a hard time understanding how it works, perhaps partially because

6条回答
  •  悲&欢浪女
    2020-12-31 10:51

    tf.tensordot should solve this problem. It supports batch operations, e.g., if you want to contract a 2D tensor with a 3D tensor, with the latter having a batch dimension.

    If a is shape [n,m] b is shape [?,m,l], then

    y = tf.tensordot(b, a, axes=[1, 1]) will produce a tensor of shape [?,n,l]

    https://www.tensorflow.org/api_docs/python/tf/tensordot

提交回复
热议问题