简体   繁体   中英

AttributeError: module 'tensorflow.contrib.learn.python.learn.ops' has no attribute 'split_squeeze'

I am using lstm predictor for timeseries prediction..

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])

But while doing regressor.fit, i am getting the error as shown in Title, need help on this..

I understand that your code imports the lstm_model from the file lstm_predictor.py when initializing your estimator. If so, the problem is caused by the following line:

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

As the README.md of that repo tells, the Tensorflow API has changed significantly . The function split_squeeze also seems to be removed from the module tensorflow.contrib.learn.python.ops. This issue has been discussed in that repository but no changes have been made in that repo since 2 years!

Yet, you can simply replace that function with tf.unstack . So simply change the line as:

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

With this I was able to get past the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM