Skip to content
This repository was archived by the owner on Aug 18, 2021. It is now read-only.

Conversation

@rubencart
Copy link

@rubencart rubencart commented Dec 18, 2018

output
gives tensor([[-1.5800e-01, ... 1.1632e-01]], grad_fn=<AddmmBackward>)
target
gives tensor([10, 29, 14, 73, 96, 55, ..., 94])
target[c]
gives tensor(10)

So criterion(output, target[c]) gives RuntimeError: dimension specified as 0 but tensor has no dimensions. See PyTorch doc's about CrossEntropyLoss, it expects inputs of shape: "Input: (N,C) where C = number of classes" and "Target: (N)".

target[c].view([1])
gives tensor([10]), which fixes the error.

return loss.data[0] / args.chunk_len gives IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number.

@rubencart
Copy link
Author

Never mind, I see that this PR is equivalent to this PR: #120

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant