-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
Flux.LSTM() returns a sequence of states #1406
Comments
You can simply take the last value with array indexing. In your example: |
yes, I figured. But would be nice to have functionality built-in, since ideally one would like to feed the last value as input to let's say a Dense layer, but if the LSTM only returns a sequence then I can't make sense how a Dense layer is supposed to process it. I was looking into the source code, it doesn't seem to provide any kwargs such that one could set return_sequences=false. Unless I am obviously missing something there, I would probably implement this functionality myself. |
I didn't catch it at first, but in your example, what you actually have is a Batch. The return value is equal to a single timestep of a LSTM |
I believe, as an easy fix, one could also plug (x->x[:,end]) in the Chain so that the succeeding layers are fed only the last state. |
Each time you call the LSTM is a timestep. You can use broadcasting, but not in the way you used. Another, very Julian, possibility would be mapslice, with time as the last dimension (good for memory management, IIRC), but I'm not sure how well is mapslice works with Zygore right now. @DhairyaLGandhi and @CarloLucibello could comment on that I think. |
You shouldn't reshape it if you want to broadcast. You should keep each timestep as an array (Input size X Batch size), and then broadcast over that. |
Hi guys,
I noticed that by default the LSTM layer returns a sequence of states instead of just the last value. Like in Keras one could set return_sequcnes=False to get only the last output, does flux also offer that?
The text was updated successfully, but these errors were encountered: