qjadud1994 / CRNN-Keras

CRNN (CNN+RNN) for OCR using Keras / License Plate Recognition
MIT License
527 stars 191 forks source link

Bi-LTSM's implementation #26

Open 4floorer opened 5 years ago

4floorer commented 5 years ago

Are you want to implement a bidirectional LSTM in the Model.py file between line 62 to 64? If the answer is YES. Here are a mistake of the Bi-LTSM's implementation.Did you forget to reverse the last_1b's output before input the add operation?

HandsomeBrotherShuaiLi commented 5 years ago

Yes, I saw this mistake too.

qjadud1994 commented 5 years ago

I do not really understand your comment. Is it reverse because I used go_backwoards = True in lstm_1b?

If it is wrong, please let me know how to fix it.

4floorer commented 5 years ago

'go_backwoards = True' in lstm_1b is only reverse the input of the lstm_1b, If you not reverse the output of the lstm_1b, for example, now the output is (S'_i, S'_i-1, ... S'_2, S'_1) will be added to (S_1, S_2,...S_i-1,S_i)(the output of the lstm_1). Are your sure your code between line 62 to 64 is to implement a Bi-LSTM or other. If you want to implement a Bi-LSTM it should be:

lstm_1 = LSTM(256, return_sequences=True, name='lstm_1')(inner) lstm_1b = LSTM(256, return_sequences=True, go_backwards=True, name='lstm_1b')(inner) reversed_lstm_1b= Lambda(lambda inputTensor: K.reverse(inputTensor, axes=1)) (lstm_1b) lstm1_merged = add([lstm_1, reversed_lstm_1b])

2019-03-07 4 56 37

qjadud1994 commented 5 years ago

Now I understand. I've been using it wrong so far.

I modified your model.py code with your help.

Thank you.

HandsomeBrotherShuaiLi commented 5 years ago

Why not try Bidirectional layer = Bidirectional(LSTM(256, return_sequences=True, kernel_initializer='he_normal'), merge_mode='concat')(layer)

jewelcai commented 5 years ago

Why not try Bidirectional layer = Bidirectional(LSTM(256, return_sequences=True, kernel_initializer='he_normal'), merge_mode='concat')(layer)

I also wonder why.. Is there any problem with this?