Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bi-LTSM's implementation #26

Open
4floorer opened this issue Feb 28, 2019 · 6 comments
Open

Bi-LTSM's implementation #26

4floorer opened this issue Feb 28, 2019 · 6 comments

Comments

@4floorer
Copy link

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
Copy link

Yes, I saw this mistake too.

@qjadud1994
Copy link
Owner

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
Copy link
Author

4floorer commented Mar 7, 2019

'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
Copy link
Owner

qjadud1994 commented Mar 7, 2019

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

I modified your model.py code with your help.

Thank you.

@HandsomeBrotherShuaiLi
Copy link

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

@jewelcai
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants