How does tensorflow batch_matmul work?

前端 未结 6 992
迷失自我
迷失自我 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:57

    You can imagine it as doing a matmul over each training example in the batch.

    For example, if you have two tensors with the following dimensions:

    a.shape = [100, 2, 5]
    b.shape = [100, 5, 2]
    

    and you do a batch tf.matmul(a, b), your output will have the shape [100, 2, 2].

    100 is your batch size, the other two dimensions are the dimensions of your data.

提交回复
热议问题