fastnlp / fastNLP

fastNLP: A Modularized and Extensible NLP Framework. Currently still in incubation.
https://gitee.com/fastnlp/fastNLP
Apache License 2.0
3.05k stars 451 forks source link

请教一下根据教程学习时出现的问题 #327

Closed forgotton-wind closed 3 years ago

forgotton-wind commented 3 years ago

代码大致如下: 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 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.

yhcc commented 3 years ago

感谢您的反馈,这是因为pytorch版本太高了,建议将pytorch降级到1.5以下。我们会尽快更新以下代码适配更高版本的pytorch~

forgotton-wind commented 3 years ago

好的,谢谢

shan37ya commented 3 months ago

你好,您的代码还维护吗,cn-char-fastnlp-100d这个文件下载不了,可以重新提供一个下载地址嘛