yanwii / seq2seq

基于Pytorch的中文聊天机器人 集成BeamSearch算法
Apache License 2.0
241 stars 87 forks source link

no model错误 #23

Open ashleyhyx opened 5 years ago

ashleyhyx commented 5 years ago

C:\ProgramData\Anaconda3\envs\torch\python.exe E:/hyx/seq2seq-master/seq2seq.py train C:\ProgramData\Anaconda3\envs\torch\lib\site-packages\torch\nn\modules\rnn.py:54: UserWarning: dropout option adds dropout after all but last recurrent layer, so non-zero dropout expects num_layers greater than 1, but got dropout=0.05 and num_layers=1 "num_layers={}".format(dropout, num_layers)) Error(s) in loading state_dict for seq2seq: size mismatch for encoder.embedding.weight: copying a param with shape torch.Size([600, 100]) from checkpoint, the shape in current model is torch.Size([14, 100]). size mismatch for decoder.embedding.weight: copying a param with shape torch.Size([1600, 100]) from checkpoint, the shape in current model is torch.Size([15, 100]). size mismatch for decoder.out.weight: copying a param with shape torch.Size([1600, 200]) from checkpoint, the shape in current model is torch.Size([15, 200]). size mismatch for decoder.out.bias: copying a param with shape torch.Size([1600]) from checkpoint, the shape in current model is torch.Size([15]). No model! 还有下面的报错 Traceback (most recent call last): File "E:/hyx/seq2seq-master/seq2seq.py", line 436, in seq.train() File "E:/hyx/seq2seq-master/seq2seq.py", line 210, in train loss, logits = self.step(inputs, targets, self.max_length) File "E:/hyx/seq2seq-master/seq2seq.py", line 271, in step return loss.data[0] / target_length, decoder_outputs IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number 怎么调都不对,求指点~~

yanwii commented 5 years ago

从no model的错误来看,是模型文件和模型不匹配的问题,删掉模型文件重新训练。第二个错误是loss这个tensor为空,也就是对应的input为空,检查一下输入数据即可。