LoginSignup
4
6

More than 5 years have passed since last update.

tensorflowのRNN関連でraise ImportError("This module is deprecated. Use tf.nn.rnn_* instead.")とエラーが出たときの解決方法

Last updated at Posted at 2016-07-23

いろいろなRNNのサンプルコードを動かす時に頻繁に遭遇した問題です。

結論

https://github.com/tensorflow/tensorflow/issues/2685
の下から2番目が解決方法になり得ると思います。

from tensorflow.models.rnn import rnn, rnn_cell
とか
from tensorflow.models.rnn import rnn
from tensorflow.models.rnn import rnn_cell
のfromで始まるRNN関連の記述をコメントアウトし、

raise ImportError("This module is deprecated. Use tf.nn.rnn_* instead.")
といわれてるので、

以降のコードの部分で、
「rnnをtf.nn.rnnとしたり、rnn_cellをtf.nn.rnn_cellというように、tf.nn.をRNN関連の関数の前に付け足す」
ことで、コードが動くようになります。直接指定してあげる必要があるみたいですね。

参照したURLによると、
Possibly some repackaging needs to be done because currently importing using namespaces returns ImportError:
と書いてあるので、repackaging関連の問題みたいです。

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6