handwritten-sequence-tensorflow icon indicating copy to clipboard operation
handwritten-sequence-tensorflow copied to clipboard

MD-LSTM

Open wellescastro opened this issue 8 years ago • 9 comments

Hi!

Is there any plan to support Multi-Directional Multi-Dimensional LSTMs? If you with, i'm available to help.

Thanks, Dayvid Castro.

wellescastro avatar May 02 '17 18:05 wellescastro

hi, i have tried to implement a multidimentional LSTM, here is a old version of my code http://stackoverflow.com/questions/42071074/multidimentional-lstm-tensorflow . I am not sure that it actually learns something. but we can try to make it better. also there is a branch that has a implementation with mdlstm, but i think it did not work very well!

johnsmithm avatar May 02 '17 18:05 johnsmithm

I have used your MDLSTM code in your stackoverflow answer. But it seems not converge in my task. Have you test successfully in your task ?

Duum avatar Jun 01 '17 08:06 Duum

i have made a test with a matrix of zeros, and i put some ones in it, and train the MDLSTM to count the ones and it converges. but with images of text i did not succeed, maybe there is an error of initialization is not correct.

johnsmithm avatar Jun 01 '17 09:06 johnsmithm

@johnsmithm Is this right?

    w,h = int(shape[1]/sh[0]),int(shape[2]/sh[1])
    features = sh[1]*sh[0]*shape[3]
    batch_size = shape[0]
    x =  tf.reshape(input_data, [batch_size,h,w, features])

I know MDLSTM need input to split to blocks, But I think the reshape fucntion above will damage the image distribution .

Duum avatar Jun 02 '17 02:06 Duum

you are right, it is needed to split sh[0] times the input in the second dimension(height), then each slice split sh[1] the third dimension.

lines = tf.split(input_data,h,axis=1)#have a list of h blocks of sh[0] lines
x = []
for line in lines:#shape[0], sh[0], shape[2], shape[3] - bs, sh[0], total width, chanels
  line = tf.transpose(line,[0,2,1,3])
  line = tf.reshape(line,[batch_size,1,w,features])
  x.append(line)
x = tf.pack(x,axis=1)

johnsmithm avatar Jun 02 '17 08:06 johnsmithm

Good, have you test it in your image task? If you test it successfully, please tell me.

Duum avatar Jun 02 '17 08:06 Duum

i have not test it yet

johnsmithm avatar Jun 02 '17 08:06 johnsmithm

I haven't found a mdlstm of tensorflow version work well so far, I hope it works! And I will test it also.

Duum avatar Jun 02 '17 08:06 Duum

it works, here is the code https://github.com/johnsmithm/mdlstm

johnsmithm avatar Jun 04 '17 11:06 johnsmithm