RuntimeError: The size of tensor a (3) must match the size of tensor b (516) at non-singleton dimension 0

Hi I am trying to reproduce results of the paper using its official code and pre-trained models.

But i could not make it because loss_func_mse causes

RuntimeError: The size of tensor a (3) must match the size of tensor b (516) at non-singleton dimension 0.

outputs, feas, updated_feas, m_items_test, softmax_score_query, softmax_score_memory, _, _, _,
compactness_loss = model.forward(imgs[:,0:34], m_items_test, False)
mse_imgs = torch.mean(loss_func_mse((outputs[0]+1)/2, (imgs[0,3
4:]+1)/2)).item()

outputs dimension : [1 3 256 256]
imgs : [1 528 256 256]

How can I fix this?

You would have to check why these tensors have different shapes, which could be caused by an error in the model architecture, a typo using the wrong variable name, etc.
Based on the shapes it seems as if output might have the same dimensions as an image tensor input.

1 Like