Concatenate feature maps with different dimension

Hi. I was trying to merge feature maps that I got from two different encoders which have different dimensions.

simclr_features: torch.Size([543, 512]) imagenet_features: torch.Size([543, 1024])

so I wanted: torch.Size([543, 1536]). what is a possible solution to do that?

Hi,
Use torch.cat:

x = torch.randn(3, 5)
y = torch.randn(3, 6)
z = torch.cat((x, y), dim=1)
print(z.shape)

out -

torch.Size([3, 11])
1 Like