Skip to content

RuntimeError: The size of tensor a (784) must match the size of tensor b (28) at non-singleton dimension 3 #1

@raniasaidi

Description

@raniasaidi

Hi ,
Hope you are doing well. When i run python train.py, i have this error:

model [VIGANModel] was created
create web directory ./checkpoints/experiment_name/web...
Start training
step 1
/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py:1569: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.
  warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/loss.py:432: UserWarning: Using a target size (torch.Size([1, 1, 28, 28])) that is different to the input size (torch.Size([1, 784])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
  return F.mse_loss(input, target, reduction=self.reduction)
Traceback (most recent call last):
  File "train.py", line 34, in <module>
    model.optimize_parameters_pretrain_AE()
  File "/content/VIGAN/models/VIGAN_model.py", line 282, in optimize_parameters_pretrain_AE
    self.backward_AE_pretrain()
  File "/content/VIGAN/models/VIGAN_model.py", line 184, in backward_AE_pretrain
    self.loss_AE_pre = self.criterionAE(AErealA, self.real_A) + self.criterionAE(AErealB, self.real_A)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/loss.py", line 432, in forward
    return F.mse_loss(input, target, reduction=self.reduction)
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py", line 2542, in mse_loss
    expanded_input, expanded_target = torch.broadcast_tensors(input, target)
  File "/usr/local/lib/python3.6/dist-packages/torch/functional.py", line 62, in broadcast_tensors
    return _VF.broadcast_tensors(tensors)
RuntimeError: The size of tensor a (784) must match the size of tensor b (28) at non-singleton dimension 3

Is there any solution for this ?
Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions