Closed QingkaiZeng closed 5 years ago
Hi, thanks for raising this issue.
The errors include one line in crf.py "File "/afs/crc.nd.edu/user/q/qzeng/Multi-BioNER/model/crf.py", line 309, in forward mask[idx].contiguous().view(bat_size, 1).expand(bat_size, self.tagset_size)).contiguous().view(bat_size, -1)"
Could you try to replace Line 308-309 with the following code?
mask_idx = mask[idx, :].view(bat_size, 1).expand(bat_size, self.tagset_size) partition.maskedscatter(mask_idx, cur_partition.masked_select(mask_idx))
Thanks for your replying. But here is still some bug as follow.
Traceback (most recent call last):
File "train_wc.py", line 286, in
It seems that you are using pytorch 0.4? Sorry that this repo only supports pytorch 0.3.x or lower.
Please also try to use the following line to replace 308-309: partition = utils.switch(partition, cur_partition, mask[idx].view(bat_size, 1).expand(bat_size, self.tagset_size)).view(bat_size, -1)
Hi, I run your code by shell, but it does not work. The Traceback result is as follow.
Traceback (most recent call last): File "train_wc.py", line 263, in
loss = crit_ner(scores, tg_v, mask_v)
File "/afs/crc.nd.edu/user/q/qzeng/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/afs/crc.nd.edu/user/q/qzeng/Multi-BioNER/model/crf.py", line 309, in forward
mask[idx].contiguous().view(bat_size, 1).expand(bat_size, self.tagset_size)).contiguous().view(bat_size, -1)
File "/afs/crc.nd.edu/user/q/qzeng/Multi-BioNER/model/utils.py", line 66, in switch
catvec = torch.cat([vec1.view(-1, 1), vec2.view(-1, 1)], dim=1)
RuntimeError: invalid argument 2: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Call .contiguous() before .view(). at /pytorch/aten/src/TH/generic/THTensor.cpp:237