【问题标题】:Error when using optim.minimize from Hyperas从 Hyperas 使用 optim.minimize 时出错
【发布时间】:2020-01-15 23:16:30
【问题描述】:

我正在尝试使用 Hyperas 中的 optim.minimize。运行的代码是google colab,python 3 + GPU。

当我运行这个时:

best_run, best_model = optim.minimize(model=create_model, data=new_data, algo=tpe.suggest,max_evals=100, trials=Trials(), notebook_name='xxxxxx')

抛出此错误:

......

/usr/lib/python3.6/inspect.py in getfile(object)
    664         return object.co_filename
    665     raise TypeError('{!r} is not a module, class, method, '
--> 666                     'function, traceback, frame, or code object'.format(object))

类型错误:

[6743 行 x 10 列] 不是模块、类、方法、函数, 回溯、框架或代码对象

有什么线索吗?

谢谢!

【问题讨论】:

  • 能否提供可重现的代码或colab中代码的链接?

标签: python tensorflow hyperas


【解决方案1】:

optim.minimize 的数据必须是方法, 我猜你使用 numpy 数组作为 optim.minimize ('new_data') 的输入

new_data 应改为如下:

def new_data() :

  return x_train, y_train, x_test, y_test

best_run, best_model = optim.minimize(model=create_model, data=new_data, algo=tpe.suggest,max_evals=100, trials=Trials(), notebook_name='xxxxxx')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-08
    • 2017-09-17
    相关资源
    最近更新 更多