Merging tensors as 'direct sum'

Hi guys,

I am having troubles with a simple operation. I would like to combine two tensors of forms ( torch.Size([28, 1, 28, 1], torch.Size([1, 28, 1, 28] ) into a single tensor of size torch.Size([ 28, 28, 28, 28]) as a direct sum, i.e., without broadcasting operations.

(Note that this is not the case with, for example, sum, as it broacasts sums and thus modifies the values of the original tensors).

Thanks a lot! :slight_smile:

David

Hi,

I’m not sure to understand what you mean by “as a direct sum, i.e., without broadcasting operations.”?
Could you give an example with small Tensors showing which value you want in the output?