CRNN-Keras icon indicating copy to clipboard operation
CRNN-Keras copied to clipboard

Bi-LTSM's implementation

Open 4floorer opened this issue 5 years ago • 6 comments

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?

4floorer avatar Feb 28 '19 08:02 4floorer

Yes, I saw this mistake too.

HandsomeBrotherShuaiLi avatar Mar 04 '19 15:03 HandsomeBrotherShuaiLi

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.

qjadud1994 avatar Mar 07 '19 08:03 qjadud1994

'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

4floorer avatar Mar 07 '19 08:03 4floorer

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

I modified your model.py code with your help.

Thank you.

qjadud1994 avatar Mar 07 '19 10:03 qjadud1994

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

HandsomeBrotherShuaiLi avatar Mar 13 '19 11:03 HandsomeBrotherShuaiLi

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?

jewelcai avatar May 22 '19 11:05 jewelcai