错误:
File "C:\Users\18474\AppData\Local\Programs\Python\Python38\lib\site-packages\fastNLP\embeddings\static_embedding.py", line 182, in init
embedding = self._load_with_vocab(model_path, vocab=vocab, init_method=init_method)
File "C:\Users\18474\AppData\Local\Programs\Python\Python38\lib\site-packages\fastNLP\embeddings\static_embedding.py", line 299, in _load_with_vocab
self.register_buffer('words_to_words', torch.full((len(vocab), ), fill_value=unknown_idx).long())
RuntimeError: Providing a bool or integral fill value without setting the optional dtype or out arguments is currently unsupported. In PyTorch 1.7, when dtype and out are not set a bool fill value will return a tensor of torch.bool dtype, and an integral fill value will return a tensor of torch.long dtype.
代码大致如下: loader = CWSLoader(dataset_name='pku') data_bundle = loader.load() data_bundle = CWSPipe().process(data_bundle) embed = StaticEmbedding(vocab=data_bundle.get_vocab('chars'), model_dir_or_name='cn-char-fastnlp-100d')
错误: File "C:\Users\18474\AppData\Local\Programs\Python\Python38\lib\site-packages\fastNLP\embeddings\static_embedding.py", line 182, in init embedding = self._load_with_vocab(model_path, vocab=vocab, init_method=init_method) File "C:\Users\18474\AppData\Local\Programs\Python\Python38\lib\site-packages\fastNLP\embeddings\static_embedding.py", line 299, in _load_with_vocab self.register_buffer('words_to_words', torch.full((len(vocab), ), fill_value=unknown_idx).long()) RuntimeError: Providing a bool or integral fill value without setting the optional
dtype
orout
arguments is currently unsupported. In PyTorch 1.7, whendtype
andout
are not set a bool fill value will return a tensor of torch.bool dtype, and an integral fill value will return a tensor of torch.long dtype.