Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于使用自己的训练集发生的错误 #6

Open
huidemie opened this issue Dec 7, 2019 · 1 comment
Open

关于使用自己的训练集发生的错误 #6

huidemie opened this issue Dec 7, 2019 · 1 comment

Comments

@huidemie
Copy link

huidemie commented Dec 7, 2019

作者您好,我在训练的时候用了自己的数据集,然后程序报了下面这样的错。我找了很久但还是不知道问题出在哪里,不知您是否可以回答,谢谢。

Traceback (most recent call last):
File "D:/PycharmProjects/github/main.py", line 83, in
train(data)
File "D:/PycharmProjects/github/main.py", line 38, in train
loss = model.neg_log_likelihood_loss(*model_input)
File "D:\PycharmProjects\github\model\model.py", line 17, in neg_log_likelihood_loss
outs = self.lstm.get_output_score(*args)
File "D:\PycharmProjects\github\model\model.py", line 55, in get_output_score
lstm_out = self.get_lstm_features(*args)
File "D:\PycharmProjects\github\model\model.py", line 45, in get_lstm_features
pos_lstm_out = self.posBiLSTM.get_lstm_features(tag_inputs, seq_lengths)
File "D:\PycharmProjects\github\model\model.py", line 80, in get_lstm_features
pos_embs = self.pos_embeddings(pos_inputs)
File "H:\Anaconda3\envs\pytorch_cpu\lib\site-packages\torch\nn\modules\module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "H:\Anaconda3\envs\pytorch_cpu\lib\site-packages\torch\nn\modules\sparse.py", line 114, in forward
self.norm_type, self.scale_grad_by_freq, self.sparse)
File "H:\Anaconda3\envs\pytorch_cpu\lib\site-packages\torch\nn\functional.py", line 1467, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: index out of range: Tried to access index 46 out of table with 15 rows. at C:\w\1\s\windows\pytorch\aten\src\TH/generic/THTensorEvenMoreMath.cpp:237

@huidemie
Copy link
Author

huidemie commented Dec 7, 2019

作者您好,我已经找到了错误的地方,应该是您的代码有一点小错误,但是在提供的三个标准数据集上刚好没有触发这个错误。具体是在model.py第75行左右,这个地方
self.pos_embeddings = init_embedding(data.tag_alphabet.size(), self.pos_emb_dim)
您应该是误写成了
self.pos_embeddings = init_embedding(data.dict_alphabet.size(), self.pos_emb_dim)
请您确认一下是不是写错了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant