Expanding a tensor in dim 0 using torch.nn

Hi all, how can I change a tensor [512,512,3,3] to [1024,512,3,3] using torch.nn?
any help would be really appreciated.

Usually dim0 represents the batch dimension and thus contains the samples. Increasing the sample count of the batch via neural network operations sounds uncommon so could you describe what the use case is and if you really want to increase the number of samples?

Dear @ptrblck, I try to use the output of intermediate layer. The dimension of this output is 512,512,3,3 I need to compare the distance between this tensor to another one with shape 1024,512,3,3. I need to convert these tensors to a same shape. How can I do that?

You could e.g. repeat or interpolate the tensor, but more importantly you should still check what this dimension represents and if you really want to manipulate this dimension as it’s usually the batch dimension.