KEMBAR78
Improve error message for RuntimeError: inconsistent tensor size in RNN · Issue #3851 · pytorch/pytorch · GitHub
Skip to content

Improve error message for RuntimeError: inconsistent tensor size in RNN #3851

@oneTaken

Description

@oneTaken

I run RNN sucessfully with the code.

rnn = nn.RNN(features, hidden_size, num_layers)
o, hidden = rnn(x, hidden)

and I run embedding example. Then, got RuntimeError.

RuntimeError: inconsistent tensor size, expected r_ [5 x 25], t [5 x 25] and src [2 x 25] to 
have thesame number of elements, but got 125, 125 and 50 elements respectively at 
/opt/conda/conda-bld/pytorch_1503970438496/work/torch/lib/TH/generic/THTensorMath.c:887

I set batch_first=True to use Embedding

x.size is [5, 8, 15]
hidden_size is [5, 2, 25]

nothing seems wrong.
And the error info seems not the dim problem?
The error is so strange.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions