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

(Xiaoxing Zeng) #1

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?


(Alban D) #2

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

(Xiaoxing Zeng) #3

Thanks,@albanD. you surgesstion works.