I’ve the following code where I want to concatenate captions and features. The captions tensor size is [5, 14, 256] and the features size after squeezing is [5, 1, 15000]. the torch.cat line is returning an error as follows:
RuntimeError: Sizes of tensors must match except in dimension 2. Got 256 and 15000 (The offending index is 0)
I am curious how to properly concatenate them?
As a reference, I found this link but couldn’t figure out my solution:
Concatenate tensor of 3 dimensions to tensor of 1 dimension while keeping first dimension - PyTorch Forums
	def forward(self, features, captions, lengths):
	    """Decode image feature vectors and generates captions."""
	    embeddings = self.embed(captions)
	    embeddings = torch.cat((features.unsqueeze(1), embeddings), 1)
	    packed = pack_padded_sequence(embeddings, lengths, batch_first=True) 
	    hiddens, _ = self.lstm(packed)
	    outputs = self.linear(hiddens[0])
	    return outputs