import torchtext
ENGLISH = torchtext.data.Field(tokenize=tokenizer_english, lower=True, init_token="<sos>", eos_token="<eos>")错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-12-2a3d11c77e7d> in <module>
----> 1 ENGLISH = torchtext.data.Field(tokenize=tokenizer_english, lower=True, init_token="<sos>", eos_token="<eos>")
AttributeError: module 'torchtext.data' has no attribute 'Field'由于某些原因,它不会导入torchtext.data.Field,即使这是文档中的内容
发布于 2021-04-05 04:47:13
BC Breaking Legacy在v0.9.0版本中,我们将以下遗留代码移至torchtext.legacy。这是修改torchtext库工作的一部分,其动机已在第#664期中讨论:
torchtext.legacy.data.field
torchtext.legacy.data.batch
torchtext.legacy.data.example
torchtext.legacy.data.iterator
torchtext.legacy.data.pipeline
torchtext.legacy.datasets我们有一个迁移教程来帮助用户切换到v0.9.0版本中的torchtext数据集。对于仍然想要遗留组件的用户,他们可以将遗留组件添加到导入路径中。
用ENGLISH = torchtext.legacy.data.field(tokenize=tokenizer_english, lower=True, init_token="<sos>", eos_token="<eos>")试试吧
https://stackoverflow.com/questions/66945577
复制相似问题