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

Update 文本分类.rst #369

Closed baiziru closed 3 years ago

baiziru commented 3 years ago

pytorch1.7 之后的版本需要增加".cpu()"转换,否则会报错:RuntimeError: ‘lengths‘ argument should be a 1D CPU int64 tensor, but got 1D cuda:0 Long tensor。

Description:简要描述这次PR的内容

Main reason: 做出这次修改的原因

Checklist 检查下面各项是否完成

Please feel free to remove inapplicable items for your PR.

Changes: 逐项描述修改的内容

Mention: 找人review你的PR

@修改过这个文件的人 @核心开发人员

baiziru commented 3 years ago

修改测试代码缺陷。

yhcc commented 3 years ago

感谢您的关注,这个问题,我们在dev分支 https://github.com/fastnlp/fastNLP/blob/595fc1d455c57de2b27d144e89992f2493527293/fastNLP/modules/encoder/lstm.py#L73 做了处理了。这个是由于pytorch1.7版本以上带来的问题。由于已经解决,所以我就不把你这个merge进去了。