I wrote it in the sample code for beginners of TensorFlow RNN (Try RNN of TensorFlow with a basic model), but the version of TensorFlow has been upgraded. There are some parts that are stuck, so I will briefly summarize them.
OSX python 3.5 TensorFlow r0.11
import
When performing RNN related inport, up to v.0.8
from tensorflow.models.rnn import rnn, rnn_cell
However, due to a problem related to repackaging,
ImportError: This module is deprecated. Use tf.nn.rnn_* instead.
I get the error.
Therefore, the import part of rnn and rnn_cell is deleted, and the part using rnn and rnn_cell is deleted.
# rnn_cell.BasicLSTMCell( ->
tf.nn.rnn_cell.BasicLSTMCell(...
# rnn( ->
tf.nn.rnn(...
Please change it to.
BasicLSTMCell
Even if you fix the above error
cell = tf.nn.rnn_cell.BasicLSTMCell(
num_of_hidden_nodes, forget_bias=forget_bias)
rnn_output, states_op = tf.nn.rnn(cell, in4, initial_state=istate_ph)
In the part like
TypeError: 'Tensor' object is not iterable.
Error may be thrown.
This is because the default argument of `` `BasicLSTMCellhas changed, and
state_is_tuple```, which determines whether tuple type is allowed or combined as the return value format, has changed from False to True. Because it is.
Therefore, if it is the above code
cell = tf.nn.rnn_cell.BasicLSTMCell(
num_of_hidden_nodes, forget_bias=forget_bias, state_is_tuple=False)
rnn_output, states_op = tf.nn.rnn(cell, in4, initial_state=istate_ph)
And state_is_tuple = False
should be specified in the argument of BasicLSTMCell
.
However, regarding this, the Official Document states that it will be abolished soon. Eventually, it will be necessary to change the writing style again.