Python textcat->architecture额外字段不允许

Python textcat->architecture额外字段不允许,python,pycharm,data-analysis,spacy,Python,Pycharm,Data Analysis,Spacy,我一直在尝试练习从本教程中学到的东西:使用PyCharm 这一行: textcat.add_label("pos") textcat = nlp.create_pipe("textcat", config={"architecture": "simple_cnn"}) 生成了一个警告: 在“单据->单据|单据->单据”中找不到引用“添加标签” 我知道这是因为nlp.create_pipe生成的文档不是字符串,而是

我一直在尝试练习从本教程中学到的东西:使用PyCharm

这一行:

textcat.add_label("pos")
textcat = nlp.create_pipe("textcat", config={"architecture": "simple_cnn"})
生成了一个警告: 在“单据->单据|单据->单据”中找不到引用“添加标签”

我知道这是因为nlp.create_pipe生成的文档不是字符串,而是因为我不知道在这种情况下该怎么办!我还是运行了脚本,但是我从这一行得到了一个错误:

textcat.add_label("pos")
textcat = nlp.create_pipe("textcat", config={"architecture": "simple_cnn"})
错误消息:

raise ConfigValidationError(
thinc.config.ConfigValidationError:

Config validation error

textcat -> architecture extra fields not permitted

{'nlp': <spacy.lang.en.English object at 0x0000015E74F625E0>, 'name': 'textcat', 'architecture': 'simple_cnn', 'model': {'@architectures': 'spacy.TextCatEnsemble.v2', 'linear_model': {'@architectures': 'spacy.TextCatBOW.v1', 'exclusive_classes': True, 'ngram_size': 1, 'no_output_layer': False}, 'tok2vec': {'@architectures': 'spacy.Tok2Vec.v2', 'embed': {'@architectures': 'spacy.MultiHashEmbed.v1', 'width': 64, 'rows': [2000, 2000, 1000, 1000, 1000, 1000], 'attrs': ['ORTH', 'LOWER', 'PREFIX', 'SUFFIX', 'SHAPE', 'ID'], 'include_static_vectors': False}, 'encode': {'@architectures': 'spacy.MaxoutWindowEncoder.v2', 'width': 64, 'window_size': 1, 'maxout_pieces': 3, 'depth': 2}}}, 'threshold': 0.5, '@factories': 'textcat'}
我正在使用:

Pycharm v:2019.3.4 python v:3.8.6 空间五:3.0.5
多亏了@polm23,整个问题都是因为我使用了比本教程作者更新的spaCy版本

矿山:3.0.5 作者:2.3.2


现在,我刚刚降低了spacy的级别,以便能够继续学习教程。

伙计!那个完整的空间升级真的抹杀了那个教程吗

有几件事你也许可以解决。我还没有完全修复那个坏掉的教程。它在待办事项清单上。然而,我确实回避了你的问题

textcat = nlp.create_pipe("textcat", config={"architecture": "simple_cnn"})
此“创建\u管道”行为已被弃用,因此您可以使用“添加\u管道”直接添加到工作流中。因此,您可以做以下一件事:

from spacy.pipeline.textcat import single_label_cnn_config

<more good code>

nlp = spacy.load("en_core_web_trf")
if "textcat" not in nlp.pipe_names:
     nlp.add_pipe('textcat', config=single_label_cnn_config, last=True)
textcat = nlp.get_pipe('textcat')
textcat.add_label("pos")
textcat.add_label("neg")

让我知道这是否有意义和帮助。在接下来的几周里,我将尝试完全从spaCy修改本教程。

看起来本教程是针对spaCy v2的,但您使用的是v3。添加管道的方式在v3中发生了重大变化;我建议您看一下快速入门,然后,它可以生成一个textcat示例。事实上,你是对的,先生,这是因为我使用的是比教程作者更新的spacy版本。谢谢。谢谢你的回答,但不幸的是,出现了更多的错误,因为我是全新的,我无法解决它们,所以我再次降级到spacy 2.3.5,但我会关注你的教程,因为它对像我这样的初学者来说非常清晰,我会用新的教程回答我的问题。嗨,我尝试使用您的添加管道解决方案,但出现以下错误Spacy 3.0.6:ValueError:[E962]接收到管道“textcat”的不正确配置。应为dict,获得:。