-
Notifications
You must be signed in to change notification settings - Fork 112
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
Simple example #8
Comments
Yes On Tue, Mar 10, 2015, 9:01 AM allchemist notifications@github.com wrote:
|
Here's a very, very simple example that might help. It doesn't do anything useful, but it expands on the examples in the README to make something that will run.
|
Big thanks! |
Thanks !!! |
Sorry to bother, please help understand training data preparation. As i understand, LSTM block recieves one value and returnes one value. So to make it learn a sequence we should prepare known sequence 'seq' as pairs [seq[1] , seq[2]], [seq[2] , seq[3]], [seq[3] , seq[4]] etc (first elem is train input, second - train target) I tried different train data, but didnt manage to achieve the recurrence effect, so 'predict_func' returns same result on several repeated calls on same input. Looks like i failed in data preparation. Or it just resets its state after each 'predict_func' call? If it isnt much trouble, can you show an example with sequence forecasting? |
@mheilman Thanks for your code. But can I ask you how extend it to minibatch case? I tried to modified your code for minibatch case, but I suffered problems with the input . Can you give me some help? Thanks. |
Sorry @stephenjia, but I don't have a good enough understanding of the best way to do that at the moment. One idea is to make another scan operation that iterates over the examples in a minibatch and makes updates for each (using the existing scan op). I'm not sure that's a good approach, though. |
@mheilman Thanks all the same. I also tried the method in README file but I still got mistakes. I will try to find where I am wrong |
@stephenjia @mheilman To get a minibatch case to work with LSTMs in a sequence forecasting setting here is one way to get this to work: Suppose you have
Build some layers out of LSTMs:
Add a classifier: Construct the recurrent prediction:
Store your mini batch as one big matrix with one row per example (if all examples don't have the same length then pad them with 0s or something else):
Now the error is as follows, we apply KL divergence at each timestep between a prediction and the next tilmestep observation (replace and tell the error where the sequences start:
Tell the system what sequence needs to be forecasted (here we're just forecasting ourselves 1 step ahead):
Compute gradient descent:
|
@JonathanRaiman Thanks for your detailed reply. I modified @mheilman example based on your suggestion, now I only play with the forward propagation part. However, there is a problem even before scan operation, says 'IndexError: tuple index out of range'. #Here's a very, very simple example that might help. It doesn't do anything useful, but it expands on the #examples in the README to make something that will run. import numpy as np from theano_lstm import (create_optimization_updates, Layer, LSTM, StackedCells, masked_loss) import random
def main():
if name == "main": |
@stephenjia Sounds like I made a typo somewhere. I'll have a look this weekend and send you a revised version |
@JonathanRaiman Thanks a lot. |
@JonathanRaiman, @mheilman |
@mheilman @stephenjia Here's a better example for sequence forecasting that runs (no typos this time) with some comments on what everything does. |
nice! |
@JonathanRaiman @mheilman thx! |
Hello!
Can you please provide a simple example of usage?
Thanks!
The text was updated successfully, but these errors were encountered: