解决AttributeError: module ‘torchtext.data‘ has no attribute ‘Field‘问题(Datasets,Example等)

2023-11-02

1.torchtext安装版本对应

torch版本:1.x.y

torchtext版本:1.x+1,y

 

2.解决AttributeError: module 'torchtext.data' has no attribute 'Field'问题

 torchtext=0.9.0版本后,将data全部移到 “legacy”下,所以在data前加一个“legacy”

# 修改前
torchtext.data.Field()
# 修改后
torchtext.legacy.data.Field()

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

解决AttributeError: module ‘torchtext.data‘ has no attribute ‘Field‘问题(Datasets,Example等) 的相关文章

随机推荐