jiesutd / NCRFpp

NCRF++, a Neural Sequence Labeling Toolkit. Easy use to any sequence labeling tasks (e.g. NER, POS, Segmentation). It includes character LSTM/CNN, word LSTM/CNN and softmax/CRF components.
Apache License 2.0
1.89k stars 446 forks source link

UserWarning: masked_fill_ (...) please use a mask with dtype torch.bool instead. #152

Closed espenhk closed 4 years ago

espenhk commented 4 years ago

When running NCRF++ in training mode with the demo file, it spews out a massive amount of the following error:

UserWarning: masked_fill_ received a mask with dtype torch.uint8, this behavior is now deprecated,please use a mask with dtype torch.bool instead.

Looking at previously closed issues, I see that manually modifying the code to cast all variables named "mask" to bool by using .bool() in stead of .byte() fixed the issue then, and apparently the issue was closed without a fix.

However, in the current version there are also other masks like this out there. I found those that are named "mask" and recast them by using .astype(bool) where .bool() wouldn't work, but I'm still getting a lot of warnings of the same type (also there does seem to be less of them).

I really don't want to go through the code with a fine-toothed comb to find every instance where an array of integers is actually used as a mask (but not named one) - can someone who's worked on the code before provide a fix?

nnakamura3 commented 4 years ago

I was faced with the same problem. And I solved the problem by downgrading pytorch to satisfy the requirements

Python: 2 or 3  
PyTorch: 1.0 
espenhk commented 4 years ago

This is a workaround, I guess, but I'd really like to run PyTorch > 1.0. Any idea why this workaround works? What was the update (to Pytorch) that broke it (and which part of NCRFpp did it break)?

jiesutd commented 4 years ago

@espenhk @gorou-gnm Same problem was solved by https://github.com/jiesutd/NCRFpp/issues/137

I will upgrade the code soon.