AttributeError:模块'tensorflow.contrib.learn.python.learn.ops'没有属性'split_squeeze'

时间:2018-02-28 05:28:02

标签: python tensorflow

我正在使用lstm预测器进行时间序列预测..

regressor = skflow.Estimator(model_fn=lstm_model(TIMESTEPS, RNN_LAYERS, DENSE_LAYERS))

validation_monitor = learn.monitors.ValidationMonitor(X['val'], y['val'],
                                                      every_n_steps=PRINT_STEPS,
                                                      early_stopping_rounds=1000)

regressor.fit(X['train'], y['train'], monitors=[validation_monitor])

但是在做regressor.fit时,我收到标题中显示的错误,需要帮助...

1 个答案:

答案 0 :(得分:2)

我了解您的代码在初始化估算工具时会从文件lstm_predictor.py导入lstm_model。如果是这样,问题是由以下行引起的:

x_ = learn.ops.split_squeeze(1, time_steps, X)

正如README.md of that repo所述,Tensorflow API has changed significantly。函数split_squeeze似乎也从模块tensorflow.contrib.learn.python.ops中删除。这个问题has been discussed存在于该存储库中,但该存储库自2年以来未进行任何更改!

然而,您可以简单地用tf.unstack替换该功能。所以只需将行更改为:

x_ =  tf.unstack(X, num=time_steps, axis=1)

通过这个我能够解决问题。