Unpack (unpack) input (placeholder) with one parameter None in tensorflow

I am trying to use LSTM with inputs with different time steps (different number of frames). The entry to rnn.static_rnn must be a tf sequence (not tf!). So, I have to convert my input to a sequence. I tried using tf.unstack and tf.split, but both of them need to know the exact size of the inputs, while one dimension of my inputs (time steps) changes to different inputs. next part of my code:

n_input = 256*256 # data input (img shape: 256*256)
n_steps = None # timesteps
batch_size = 1
# tf Graph input
x = tf.placeholder("float", [ batch_size , n_input,n_steps])
y = tf.placeholder("float", [batch_size, n_classes])
# Permuting batch_size and n_steps
x1 = tf.transpose(x, [2, 1, 0])
x1 = tf.transpose(x1, [0, 2, 1])
x3=tf.unstack(x1,axis=0)
#or x3 = tf.split(x2, ?, 0)
# Define a lstm cell with tensorflow
lstm_cell = rnn.BasicLSTMCell(num_units=n_hidden, forget_bias=1.0)

# Get lstm cell output
outputs, states = rnn.static_rnn(lstm_cell, x3, dtype=tf.float32,sequence_length=None)

      

I got the following error while using tf.unstack:

ValueError: cannot output num from form (?, 1, 65536)

There are also several discussions here and here , but none of them were helpful to me. Any help is appreciated.

+3


source to share


1 answer


As explained in here , tf.unstack

does not work if the argument is unspecified and unparsed.



In your code, after the transpositions x1

has a form [ n_steps, batch_size, n_input]

, and its value is axis=0

equal None

.

0


source







All Articles