RuntimeError: invalid argument 0: Tensors must have same number of dimensions: got 3 and 2
See original GitHub issueHi,Thank you for this perfect code,and I have learned a lot from this code.But when I run this code,I get one problem :
Traceback (most recent call last): File "main.py", line 438, in <module> train(data, save_model_dir, seg) File "main.py", line 265, in train batch_charrecover, batch_label, mask) File "/Users/fengxiachong/Desktop/PyTorchSeqLabel-master/model/bilstmcrf.py", line 33, in neg_log_likelihood_loss scores, tag_seq = self.crf._viterbi_decode(outs, mask) File "/Users/fengxiachong/Desktop/PyTorchSeqLabel-master/model/crf.py", line 162, in _viterbi_decode partition_history = torch.cat(partition_history).view(seq_len, batch_size, -1).transpose(1, RuntimeError: invalid argument 0: Tensors must have same number of dimensions: got 3 and 2 at /Users/soumith/minicondabuild3/conda-bld/pytorch_1518371252923/work/torch/lib/TH/generic/THTensorMath.c:2888
could you please help me?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (3 by maintainers)

Top Related StackOverflow Question
I just add one line
partition = partition.view(partition.size()[0], partition.size()[1], 1)in function_viterbi_decodein the for loop,now it can run,thank you very much.partition = partition.unsqueeze(-1)works also.