hycis / bidirectional_RNN

bidirectional lstm
MIT License
153 stars 52 forks source link

doubt regarding preperation of training data #10

Open shwetgarg opened 8 years ago

shwetgarg commented 8 years ago

I am trying to implement language model kind of thing using bidirectional LSTM

In unidirectional LSTM, when we prepare data, if sentence is: "A recurrent neural network is a class of artificial neural network" Then we prepare training data as follows: x1 = A(x11) recurrent(x12) y1 = neural x2 = recurrent(x21) neural(22) y2 = network and so on....

But in bidirectional LSTM, we must have different inputs for forward and backward pass for same output, like: xf1 = A(xf11) recurrent(xf12) xb1 = network(xb11) is(xb12) y1 = neural

How to specify this input for bidirectional LSTM here. Please help

hycis commented 8 years ago

@shwetgarg I don't quite understand your notation though. But the inputs to the recurrent layer will be 3 dimensional, that is (num_of_sequences * num_vectors_in_a_sequence * vector_length)

xisnu commented 8 years ago

@hycis Thank you so much for your contribution. It was life saving. I was using using this in a classic problem of digit recognition. To save my model I was using the default save method using h5py as mentioned by Keras documentation. As expected this save method failed as this unit "birnn.py" is not imported there. Do you have some other methods to save this model or I should edit the generic_utils.py? It would be much kind of you if you suggest anything regarding this. Thank you once again.

hycis commented 8 years ago

The simplest is to just use cPickle to serialize model.

Import cPickle

With open('mod.pkl', 'wb') as fout: cPickle.dump(model, fout) On Nov 19, 2015 12:29 AM, "Parthosarothi Mukherjee" < notifications@github.com> wrote:

@hycis https://github.com/hycis Thank you so much for your contribution. It was life saving. I was using using this in a classic problem of digit recognition. To save my model I was using the default save method using h5py as mentioned by Keras documentation. As expected this save method failed as this unit "birnn.py" is not imported there. Do you have some other methods to save this model or I should edit the generic_utils.py? It would be much kind of you if you suggest anything regarding this. Thank you once again.

— Reply to this email directly or view it on GitHub https://github.com/hycis/bidirectional_RNN/issues/10#issuecomment-157768565 .

xisnu commented 8 years ago

Thank you so much @hycis . I was worried about using that as Keras documentation is saying "should not use cpickle". Anyways you know that far better that me. Thanks again.