Hyperopt TypeError: 'generator' object is not subscriptable

BUG

最近复用以前的代码,结果发现了一个bug,bug如下:

      File "/home/michael/work/oanda/src/oanda/trend_prediction/find_optimal_model.py", line 124, in <module>
        main()
      File "/home/michael/work/oanda/src/oanda/trend_prediction/find_optimal_model.py", line 116, in main
        trials=trials)
      File "/home/michael/work/oanda/runtime/lib/python3.5/site-packages/hyperopt/fmin.py", line 307, in fmin
        return_argmin=return_argmin,
      File "/home/michael/work/oanda/runtime/lib/python3.5/site-packages/hyperopt/base.py", line 635, in fmin
        return_argmin=return_argmin)
      File "/home/michael/work/oanda/runtime/lib/python3.5/site-packages/hyperopt/fmin.py", line 314, in fmin
        pass_expr_memo_ctrl=pass_expr_memo_ctrl)
      File "/home/michael/work/oanda/runtime/lib/python3.5/site-packages/hyperopt/base.py", line 786, in __init__
        pyll.toposort(self.expr)
      File "/home/michael/work/oanda/runtime/lib/python3.5/site-packages/hyperopt/pyll/base.py", line 715, in toposort
        assert order[-1] == expr
    TypeError: 'generator' object is not subscriptable

原因与解决方案

思考 :考虑到之前我更新了类库,所以最先考虑的是类库问题,但是是在找不到是那个类库的问题,查了Hyperopt源码也没什么用.大概僵持了二十分钟,决定还是去Github查查issues.确实找到了解决方案.
原因与解决底层库networkx更新造成的,Hyperopt不支持networkx-2.0,我换成了1.11版本就OK了.

pip install networkx==1.11

blog :没百度到这个错误,所以写了博客,如文章题目使用关键词Hyperopt+TypeError: 'generator' object is not subscriptable可以找到,算是造福一下小白.

转载于:https://www.cnblogs.com/fonttian/p/9162729.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值