How to do element wise multiplication for two 4D unequal size tensors in pytorch?
I have got a tensor A and Tensor B. 

Size of A = [2,64,56,56]

Size of B = [2,64,29,29]

How can I perform torch.mul(A,B)? The tensors are of unequal size.


  RuntimeError: shape [2, 64, 56, 56] is invalid for input of size 107648


You can check out the documentation here: https://pytorch.org/docs/stable/torch.html#torch.mul

There, you can read:


  The shapes of input and other must be broadcastable.


You can read about broadcastability here: https://pytorch.org/docs/stable/notes/broadcasting.html#broadcasting-semantics

Lastly, it probably makes sense to think about what you want to achieve. I'm not sure what you wanted such operation to do since to have the element-wise multiplication you need the tensors to have the same shapes.
