【问题标题】:error with plotting keras NN (matplotlib) [closed]绘制keras NN(matplotlib)时出错[关闭]
【发布时间】:2018-01-22 13:24:08
【问题描述】:

我在尝试运行本教程tutorial 中的代码时遇到以下错误。我能够修复以前的错误,但由于该网络的训练需要大约 10 分钟,所以我现在卡住了。

当我转到第 254 行时,它只是一个没有代码的注释行,我看不出 plt.show 命令有什么问题。我在代码的第 254 行找不到它所说的返回语句,所以我不确定问题是什么。谁能看出来是什么?

Traceback (most recent call last):
line 52, in run_file pydev_imports.execfile(file, globals, locals)  # execute the script
line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) 
line 369, in <module> plt.show(fig1)
line 254, in show return _show(*args, **kw)

TypeError: __call__() takes 1 positional argument but 2 were given

【问题讨论】:

    标签: python matplotlib


    【解决方案1】:

    我猜你指的是教程中的plt.show(fig1)。这是完全错误的。

    您可以调用plt.show() 来显示所有处于 pyplot 状态的绘图。

    或者如果有数字fig1,您可以致电fig1.show(),但这可能不适用于jupyter notebook。

    在 Jupyter 笔记本中,您可以简单地陈述图形的名称来显示它,

    fig1
    

    【讨论】:

    • 这不是在 jupyter notebook 中运行的。我在 pycharm IDE 中运行这些是上一行 #Testing the Model y_predict, real_y_test, real_y_predict, fig1 = test_model(model, X_test, Y_test, unnormalized_bases) #Show the plot plt.show(fig1)
    • 没关系,我给了你所有的选项,无论是在 jupyter notebook 内部还是外部。
    • 感谢 fig1.show() 工作
    猜你喜欢
    • 2019-11-23
    • 2017-12-17
    • 2020-09-17
    • 1970-01-01
    • 2013-06-19
    • 2020-08-14
    • 2019-04-22
    • 2019-12-27
    • 1970-01-01
    相关资源
    最近更新 更多