Transformers: Expected object of scalar type Byte but got scalar type Bool for argument #2 'mask'

Created on 26 Nov 2019  ยท  4Comments  ยท  Source: huggingface/transformers

โ“ Questions & Help


fine tuning bert use wikitext2

Most helpful comment

Please upgrade your Pytorch version to 1.2.0+.

All 4 comments

in probability_matrix.masked_fill_(torch.tensor(special_tokens_mask, dtype=torch.bool), value=0.0)

Please, describe your environment, post the source code for reproducibility and the error.

in probability_matrix.masked_fill_(torch.tensor(special_tokens_mask, dtype=torch.bool), value=0.0)

Please upgrade your Pytorch version to 1.2.0+.

You're probably passing in a boolean tensor (true or false) instead of a byte tensor (0 or 1) for your attention mask.

Try changing

probability_matrix.masked_fill_(torch.tensor(special_tokens_mask, dtype=torch.bool), value=0.0)

to

probability_matrix.masked_fill_(torch.tensor(special_tokens_mask, dtype=torch.uint8), value=0.0)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

fabiocapsouza picture fabiocapsouza  ยท  3Comments

lcswillems picture lcswillems  ยท  3Comments

HanGuo97 picture HanGuo97  ยท  3Comments

alphanlp picture alphanlp  ยท  3Comments

yspaik picture yspaik  ยท  3Comments