How can I do multiply between two 4-dimension matrix?

HI guys:
there are two multi-dimension matrix
a=[64,10,1,1]; b=[64,10,28,28]

I found that a*b can be implemented in TensorFlow. And the result is also [64,10,28,28].
But when I used Pytorch, it didn’t work.

So how should I do?


I assume that you are looking for element-wise multiplication where the last two dimensions are broadcasted for a?
If so, you can do this with a.expand_as(b) * b

1 Like

Thanks,@albanD. you surgesstion works.