Search code examples
pythontensorflowlstmrecurrent-neural-networktflearn

Tflearn ValueError: Shape (256, ?) must have rank at least 3


    print(network.shape ) # ( ? , 256, 2, 128 ) 
    network = reshape(network,[-1,256,256])
    print(network.shape) # ( ? , 256, 256 )  batch_Size,time_stamp,features 
    network = bidirectional_rnn(network, GRUCell(32 ), GRUCell(32) )

I am trying to code a CRNN using tflearn, this is the log i get :

  File "data_clean.py", line 117, in sai_net
    network = bidirectional_rnn(network, GRUCell(32 ), GRUCell(32) )
  File "/usr/local/lib/python2.7/dist-packages/tflearn/layers/recurrent.py", line 374, in bidirectional_rnn
    dtype=tf.float32)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/rnn.py", line 405, in bidirectional_dynamic_rnn
    time_major=time_major, scope=fw_scope)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/rnn.py", line 598, in dynamic_rnn
    dtype=dtype)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/rnn.py", line 661, in _dynamic_rnn_loop
    for input_ in flat_input)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/rnn.py", line 661, in <genexpr>
    for input_ in flat_input)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_shape.py", line 654, in with_rank_at_least
    raise ValueError("Shape %s must have rank at least %d" % (self, rank))
ValueError: Shape (256, ?) must have rank at least 3

am i missing something,as tensor is of three dimensions, first one would be the batch size, that i would be feeding to the network. Similar code works perfectly on keras. am i missing something here ?


Solution

  • Seems to be a known issue: https://github.com/tflearn/tflearn/issues/818, happens with tensorflow versions 1.2 and above.