Skip to content

Please help me with the error:RuntimeError: Expected target size [32, 9490], got [32, 51] #195

Open
@2068439567

Description

@2068439567

Traceback (most recent call last):
File "D:\majority_design\image_caption\ic_train.py", line 322, in
main()
File "D:\majority_design\image_caption\ic_train.py", line 116, in main
train(train_loader=train_loader,
File "D:\majority_design\image_caption\ic_train.py", line 180, in train
loss = criterion(scores, targets)
File "D:\anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "D:\anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\loss.py", line 1164, in forward
return F.cross_entropy(input, target, weight=self.weight,
File "D:\anaconda3\envs\pytorch\lib\site-packages\torch\nn\functional.py", line 3014, in cross_entropy
return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing)
RuntimeError: Expected target size [32, 9490], got [32, 51]

When i debug the code, i found scores's size is (32, 16, 9490), but targets's size is (32, 51)

i am just a rookie of DL, please help me!!! Thank you very much!!!

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