Traceback (most recent call last):
File "/home/test/anaconda3/envs/pytorch/lib/python3.7/site-packages/transforme rs/utils/import_utils.py", line 857, in _get_module
return importlib.import_module("." + module_name, self.__name__)
File "/home/test/anaconda3/envs/pytorch/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/test/anaconda3/envs/pytorch/lib/python3.7/site-packages/transforme rs/models/bert/modeling_bert.py", line 43, in <module>
from ...modeling_utils import (
File "/home/test/anaconda3/envs/pytorch/lib/python3.7/site-packages/transforme rs/modeling_utils.py", line 39, in <module>
from .generation_utils import GenerationMixin
File "/home/test/anaconda3/envs/pytorch/lib/python3.7/site-packages/transforme rs/generation_utils.py", line 28, in <module>
from .generation_logits_process import (
File "/home/test/anaconda3/envs/pytorch/lib/python3.7/site-packages/transforme rs/generation_logits_process.py", line 379, in <module>
class NoBadWordsLogitsProcessor(LogitsProcessor):
File "/home/test/anaconda3/envs/pytorch/lib/python3.7/site-packages/transforme rs/generation_logits_process.py", line 430, in NoBadWordsLogitsProcessor
def _calc_static_bad_word_mask(self, scores: torch.FloatTensor) -> torch.Boo lTensor:
AttributeError: module 'torch' has no attribute 'BoolTensor'
因为pytorch版本为1.0.0, 但是升级到1.2.0又会导致cuda版本不匹配,所以修改/home/test/anaconda3/envs/pytorch/lib/python3.7/site-packages/transforme rs/generation_logits_process.py
代码中有 def _calc_static_bad_word_mask(self, scores: torch.FloatTensor) -> torch.BoolTensor:
static_bad_words_mask = torch.zeros(scores.shape[1])
static_bad_words_mask[self.bad_words_id_length_1] = 1
return static_bad_words_mask.unsqueeze(0).to(scores.device).bool()
将这里的BoolTensor改为ByteTensor