Tensor Flow - LSTM - Tensor Object Does Not Repeat

Hi, I am using the following function for lstm rnn cell.

def LSTM_RNN(_X, _istate, _weights, _biases): # Function returns a tensorflow LSTM (RNN) artificial neural network from given parameters. # Note, some code of this notebook is inspired from an slightly different # RNN architecture used on another dataset: # https://tensorhub.com/aymericdamien/tensorflow-rnn # (NOTE: This step could be greatly optimised by shaping the dataset once # input shape: (batch_size, n_steps, n_input) _X = tf.transpose(_X, [1, 0, 2]) # permute n_steps and batch_size # Reshape to prepare input to hidden activation _X = tf.reshape(_X, [-1, n_input]) # (n_steps*batch_size, n_input) # Linear activation _X = tf.matmul(_X, _weights['hidden']) + _biases['hidden'] # Define a lstm cell with tensorflow lstm_cell = rnn_cell.BasicLSTMCell(n_hidden, forget_bias=1.0) # Split data because rnn cell needs a list of inputs for the RNN inner loop _X = tf.split(0, n_steps, _X) # n_steps * (batch_size, n_hidden) # Get lstm cell output outputs, states = rnn.rnn(lstm_cell, _X, initial_state=_istate) # Linear activation # Get inner loop last output return tf.matmul(outputs[-1], _weights['out']) + _biases['out'] 

The output of the function is stored in the variable pred.

pred = LSTM_RNN(x, istate, weights, biases)

But it shows the following error. (which claims that the tensor object is not iterable.)

Here is the image link ERROR - http://imgur.com/a/NhSFK

Please help me with this, and I apologize if this question seems silly, as I'm pretty new to the lstm and tensor thread library.

Thanks.

+6
source share
2 answers

An error occurred while trying to unpack state using instruction c, h=state . Depending on the version of tensorflow you are using (you can check the version information by typing import tensorflow; tensorflow.__version__ in the python interpreter), in versions prior to r0.11, by default for the state_is_tuple argument when initializing rnn_cell.BasicLSTMCell(n_hidden, forget_bias=1.0) set to False . See the documentation here.

BasicLSTMCell documentation in r0.10

Since the tensorflow version is r0.11 (or the main version), by default state_is_tuple set to True . See the documentation here .

BasicLSTMCell documentation in r0.11

If you installed r0.11 or the main version of the tensor stream, try changing the initialization string BasicLSTMCell to: lstm_cell = rnn_cell.BasicLSTMCell(n_hidden, forget_bias=1.0, state_is_tuple=False) . The error you encounter should disappear. Although their page says that the behavior of state_is_tuple=False will be deprecated.

BasicLSTMCell state_is_tuple documentation

+6
source

I came across the same issue at the same time. I am just describing my circumstance, which may help for u

well

 c1_ex, T1_ex = tf. ones(10,tf. int 32) raise Type Error ... 

I found that the left side of '=' was given two vector names in advance

while the other side just returns a vector

sorry for my ineffective english

your problem really appears on line 146, not line 193

+3
source

Source: https://habr.com/ru/post/1012101/


All Articles