liu-nlper / SLTK

序列化标注工具,基于PyTorch实现BLSTM-CNN-CRF模型,CoNLL 2003 English NER测试集F1值为91.10%(word and char feature)。
362 stars 84 forks source link

运行 ./test.sh 时报 RuntimeError: value cannot be converted to type uint8_t without overflow: -1 #2

Closed KaqiKaqi closed 6 years ago

KaqiKaqi commented 6 years ago

Traceback (most recent call last): File "../test.py", line 77, in targets_list = sl_model.predict(sample_batched) File "/xunku/SLTK-master/TorchNN/layers/bilstm_crf.py", line 106, in predict path_score, best_paths = self.crf(lstm_feats, mask) File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 357, in call result = self.forward(*input, *kwargs) File "/xunku/SLTK-master/TorchNN/layers/crf.py", line 182, in forward path_score, best_path = self._viterbi_decode(feats, mask) File "/xunku/SLTK-master/TorchNN/layers/crf.py", line 130, in _viterbi_decode mask = 1 + (-1) mask RuntimeError: value cannot be converted to type uint8_t without overflow: -1

不知道这是怎么回事?

liu-nlper commented 6 years ago

你好:

你将mask = 1 + (-1) * mask改为mask = (1 - mask.long()).byte()试试。

祝好

On Tue, Mar 13, 2018 at 9:27 AM, KaqiKaqi notifications@github.com wrote:

Traceback (most recent call last): File "../test.py", line 77, in targets_list = sl_model.predict(sample_batched) File "/xunku/SLTK-master/TorchNN/layers/bilstm_crf.py", line 106, in predict path_score, best_paths = self.crf(lstm_feats, mask) File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 357, in call result = self.forward(*input, *kwargs) File "/xunku/SLTK-master/TorchNN/layers/crf.py", line 182, in forward path_score, best_path = self._viterbi_decode(feats, mask) File "/xunku/SLTK-master/TorchNN/layers/crf.py", line 130, in _viterbi_decode mask = 1 + (-1) mask RuntimeError: value cannot be converted to type uint8_t without overflow: -1

不知道这是怎么回事?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/liu-nlper/SLTK/issues/2, or mute the thread https://github.com/notifications/unsubscribe-auth/ASWWim_6M6AIbXO69y-lpGlBzNGLxcUDks5tdyCFgaJpZM4Sn8Oa .

KaqiKaqi commented 6 years ago

还是不行,报了另外一个错

Traceback (most recent call last): File "../test.py", line 77, in targets_list = sl_model.predict(sample_batched) File "/xunku/SLTK-master/TorchNN/layers/bilstm_crf.py", line 106, in predict path_score, best_paths = self.crf(lstm_feats, mask) File "/usr/local/lib/python3.5/dist-packages/torch/nn/modules/module.py", line 357, in call result = self.forward(*input, **kwargs) File "/xunku/SLTK-master/TorchNN/layers/crf.py", line 183, in forward path_score, best_path = self._viterbi_decode(feats, mask) File "/xunku/SLTK-master/TorchNN/layers/crf.py", line 146, in _viterbi_decode partition_history = torch.cat(partition_history).view( RuntimeError: invalid argument 0: Tensors must have same number of dimensions: got 3 and 2 at /pytorch/torch/lib/TH/generic/THTensorMath.c:2888

KaqiKaqi commented 6 years ago

我知道原因了。 line 134 partition_history.append(partition) 加进去的 partition 的 rank 是3,最后一维的 dim 是1 line 140 加进去的 partition 的 rank 是2。也就是说 partition, cur_bp = torch.max(cur_values, 1) 产生的 partition 的 rank 是2.

我的torch 是0.3.0, 不知道和版本有关系没有。