【问题标题】:TypeError: __init__() got multiple values for keyword argument 'add_config_file_help'TypeError:__init__() 为关键字参数“add_config_file_help”获得了多个值
【发布时间】:2018-07-28 00:27:47
【问题描述】:

我正在尝试运行 Retrieval-eval.py,但遇到以下错误:

 TypeError: __init__() got multiple values for keyword argument 'add_config_file_help'                                     

我正在使用 get_sim_score() 方法从另一个目录计算相似度分数,同时通过该方法转到 argparser.py 在这里我得到了上面显示的这个错误。这是我在 NeonArgparser() 类中的 argparser.py,我遇到了该错误。谁能帮我解决这个错误?

**class NeonArgparser(configargparse.ArgumentParser):**
    """
    Setup the command line arg parser and parse the
    arguments in sys.arg (or from configuration file).  Use the parsed
    options to configure the logging module.*emphasized text*

    Arguments:
        desc (String) : Docstring from the calling function. This will be used
                        for the description of the command receiving the
                        arguments.
    """
    def __init__(self, *args, **kwargs):
        self._PARSED = False
        self.work_dir = os.path.join(os.path.expanduser('~'), 'nervana')
        if 'default_config_files' not in kwargs:
            kwargs['default_config_files'] = [os.path.join(self.work_dir,
                                                           'neon.cfg')]
        if 'add_config_file_help' not in kwargs:
            # turn off the auto-generated config help for config files since it
            # referenced unsettable config options like --version
            kwargs['add_config_file_help'] = False

        self.defaults = kwargs.pop('default_overrides', dict())
        super(NeonArgparser, self).__init__(*args, **kwargs)

        # ensure that default values are display via --help
        self.formatter_class = configargparse.ArgumentDefaultsHelpFormatter

        self.setup_default_args()

这是异常跟踪,请看一下。

    (ronin) pratyusha@pratyusha-Q304UAK:~/Projects/ronin$ python Retrieval-Eval.py
No handlers could be found for logger "gensim.models.doc2vec"
<IPython.core.display.HTML object>
Can you suggest a spa for us?
Are transport facilities available here?
Traceback (most recent call last):
  File "Retrieval-Eval.py", line 484, in <module>
    e = evaluate(dialogue, dtype="str", concept_weight=1.0, task_weight=0)
  File "Retrieval-Eval.py", line 248, in evaluate
    retrieval2 = get_skipsim_matches(selected=questions, dtype="str", conceptW=concept_weight, taskW=task_weight)  #HERE !!!!!!!!!!!!!
  File "Retrieval-Eval.py", line 446, in get_skipsim_matches
    conceptDictionary = get_skipsim_concept_dictionary(selected[1:], dtype)   
  File "Retrieval-Eval.py", line 464, in get_skipsim_concept_dictionary
    scores = get_list_skipsim_scores(selected, dialogue, dtype)   
  File "Retrieval-Eval.py", line 430, in get_list_skipsim_scores
    score = st.get_sim_score(q1, q2)    
  File "/home/pratyusha/Desktop/neon/examples/skipthought/inference.py", line 132, in get_sim_score
    a = self.get_sentence_vec(text1)
  File "/home/pratyusha/Desktop/neon/examples/skipthought/inference.py", line 50, in get_sentence_vec
    parser = NeonArgparser(__doc__)
  File "/home/pratyusha/.virtualenvs/ronin/local/lib/python2.7/site-packages/neon/util/argparser.py", line 80, in __init__
    super(NeonArgparser, self).__init__(*args, **kwargs)
TypeError: __init__() got multiple values for keyword argument 'add_config_file_help'

谢谢你`

【问题讨论】:

  • 不要在没有说明问题所在的情况下转储代码。
  • @chrisz 我正在尝试在基于案例的推理系统中使用 skipthougt 模型执行检索任务。检索任务进展顺利,但我在产生结果时遇到此错误谢谢
  • 使用所有相关信息编辑您的问题,包括完整的异常跟踪。不要在 cmets 中回复。
  • @MadPhysicist 我已经发布了一个截图,你能帮我解决这个错误吗?这是一种紧急情况。
  • 不要发布截图。将文本作为文本发布,并正确格式化。并学会更好地管理你的时间。当您提出包含所有必要信息的适当问题时,我会为您提供帮助。

标签: django python-2.7


【解决方案1】:

这主要是由于最新版本的 ConfigArgParse 中的一个错误。 现在要让您畅通无阻,请通过运行以下命令安装最新版本以外的其他版本:

pip install --no-cache-dir ConfigArgParse&gt;=0.10.0,&lt;0.13.0

如果您在 shell 中运行,您可能需要转义一些字符:

pip install --no-cache-dir ConfigArgParse\&gt;\=0.10.0,\&lt;0.13.0

现在您应该可以运行该示例了: `

$ python examples/mnist_mlp.py -b cpu
Epoch 0   [Train |████████████████████|  469/469  batches, 0.27 cost, 1.39s]
Epoch 1   [Train |████████████████████|  469/469  batches, 0.20 cost, 1.43s]
Epoch 2   [Train |████████████████████|  469/469  batches, 0.18 cost, 1.44s]
Epoch 3   [Train |████████████████████|  468/468  batches, 0.14 cost, 1.44s]
Epoch 4   [Train |████████████████████|  468/468  batches, 0.12 cost, 1.45s]
Epoch 5   [Train |████████████████████|  468/468  batches, 0.11 cost, 1.45s]
Epoch 6   [Train |████████████████████|  468/468  batches, 0.11 cost, 1.44s]
Epoch 7   [Train |████████████████████|  468/468  batches, 0.09 cost, 1.45s]
Epoch 8   [Train |████████████████████|  468/468  batches, 0.09 cost, 1.50s]
Epoch 9   [Train |████████████████████|  468/468  batches, 0.08 cost, 1.44s]
2018-02-27 18:49:54,287 - neon - DISPLAY - Misclassification error = 2.5%`

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多