You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to implement online learning for a LSTM RNN. Does keras support online learning as of now?
If not, can someone direct us to any source on how online learning can be implemented for RNN? (atleast on a conceptual level).
naisanza, GavinDmello, BSatyaKishore, sipemu, markoarnauto and 12 more
If I train a model with a training set.
Now, Can i 're-fit' [update NOT re-train] the model with new data such that model parameters are just updated and not re-initialized.
Example:
The below model is loaded after being trained with a training dataset.
model = model_from_json(open('lstm.json').read())
model.load_weights('lstm_weights.h5')
The parameters are not only getting updated but also the learned from initial training will be overwritten. The more new_data_input you have, the more the old training will be overwritten and it's probable that the accuracy for those training data goes down. I guess you mean with online learning, that with every new input all total inputs ever used are added to the network instead of overwritten, but I don't think this is the case.
nbro, kukumayas, reydenX, AB19, gohar94 and 1 more
I'm not sure I follow exactly what Marc is trying to say (maybe he meant
to use "diminished" rather than "overwritten").
But it does bear to note that when you restart the fit(), any kind
of learning rate schedule your optimizer is following (e.g. SGD+decay
or adam) is restarted too! That means you may be updating your model
on a new small sample by using a huge learning rate, which might not
be okay.
Fixing this (to set the initial #iterations > 0) will require some
small changes to keras.optimizers. But I don't know if there's any
literature on what's actually the good way to fix this, because just
setting the #iterations to number of iterations ran before does not
sound right either. So perhaps the safest solution may be to just
use plain SGD with static learning rate for these followup fit()s.
naisanza, ricardopinto, Bronzekorean, Shanmugapriya001, jamesrichter and 6 morenbro
Yeah, I want the LSTM to learn with newer data. If it forgets what it has learnt from the older data, its fine. It needs to update itself depending on the trend in the new data.
It seems that .fit() does take care of the problem I had.
Thanks @tboquet, @pasky and @marcj
naisanza, tnlin, amineebenamor, keyochali and msmuskan
@ashwin123 : I am also looking for online learning in keras. What I understand is that:
for every datapoint , you update the model. Once a data point is used, never use it again. Is that correct ?
Also from your experience, how did your model perform ?
@ashwin123 @fchollet
Is there a way to incorporate Passive-Aggresive Algorithm [Crammer06] in updating the weights for online variant ? To be honest I am not even sure If the 2 can be connected.
Looking for some good practices of building models using online deep learning
I have put up a basic code for Online Deep Learning in Keras. https://github.com/anujgupta82/DeepNets/blob/master/Online_Learnin/Online_Learning_DeepNets.ipynb
The key difference is the way training is done - refer to cell number 9 and 17 in the notebook.
In Cell 17, I take one datapoint (as if its a streaming data) and fit the model on this datapoint. Then take next datapoint so on and so forth. Further, each datapoint is considered exactly once and no more.
There is a difference in the outcome of offline and online - On test data ofline gave a 97.98 accuracy, online learning gave 93.96 accuracy.
Is this a right way to implement online learning in Keras ?
Any suggestions on what changes can I make to online accuracy closer to offline ?
Maryleensrijan-mishra, heanylab, GavinDmello, luiscape, jagwire16 and 10 more
Activity
tboquet commentedon Mar 2, 2016
When you say online learning, do you mean this?
If it's the case, you could take a look at this example.
sjayakum commentedon Mar 3, 2016
Say,
If I train a model with a training set.
Now, Can i 're-fit' [update NOT re-train] the model with new data such that model parameters are just updated and not re-initialized.
Example:
The below model is loaded after being trained with a training dataset.
Now, when I do
Here does the above statement retrain the model from scratch or just the model parameters get updated.
pasky commentedon Mar 3, 2016
ashwinnaresh commentedon Mar 3, 2016
Okay, thank you!
marcj commentedon Mar 3, 2016
The parameters are not only getting updated but also the learned from initial training will be overwritten. The more new_data_input you have, the more the old training will be overwritten and it's probable that the accuracy for those training data goes down. I guess you mean with online learning, that with every new input all total inputs ever used are added to the network instead of overwritten, but I don't think this is the case.
pasky commentedon Mar 3, 2016
I'm not sure I follow exactly what Marc is trying to say (maybe he meant
to use "diminished" rather than "overwritten").
But it does bear to note that when you restart the fit(), any kind
of learning rate schedule your optimizer is following (e.g. SGD+decay
or adam) is restarted too! That means you may be updating your model
on a new small sample by using a huge learning rate, which might not
be okay.
Fixing this (to set the initial #iterations > 0) will require some
small changes to keras.optimizers. But I don't know if there's any
literature on what's actually the good way to fix this, because just
setting the #iterations to number of iterations ran before does not
sound right either. So perhaps the safest solution may be to just
use plain SGD with static learning rate for these followup fit()s.
ashwinnaresh commentedon Mar 4, 2016
Yeah, I want the LSTM to learn with newer data. If it forgets what it has learnt from the older data, its fine. It needs to update itself depending on the trend in the new data.
It seems that .fit() does take care of the problem I had.
Thanks @tboquet, @pasky and @marcj
anujgupta82 commentedon Apr 19, 2016
@ashwin123 : I am also looking for online learning in keras. What I understand is that:
for every datapoint , you update the model. Once a data point is used, never use it again. Is that correct ?
Also from your experience, how did your model perform ?
ashwinnaresh commentedon Apr 20, 2016
Yes, I was updating the model with a new batch of data points. The model seemed to perform well.
anujgupta82 commentedon Apr 22, 2016
@ashwin123
@fchollet
Is there a way to incorporate Passive-Aggresive Algorithm [Crammer06] in updating the weights for online variant ? To be honest I am not even sure If the 2 can be connected.
Looking for some good practices of building models using online deep learning
anujgupta82 commentedon Apr 25, 2016
I have put up a basic code for Online Deep Learning in Keras.
https://github.com/anujgupta82/DeepNets/blob/master/Online_Learnin/Online_Learning_DeepNets.ipynb
The key difference is the way training is done - refer to cell number 9 and 17 in the notebook.
In Cell 17, I take one datapoint (as if its a streaming data) and fit the model on this datapoint. Then take next datapoint so on and so forth. Further, each datapoint is considered exactly once and no more.
There is a difference in the outcome of offline and online - On test data ofline gave a 97.98 accuracy, online learning gave 93.96 accuracy.
Is this a right way to implement online learning in Keras ?
Any suggestions on what changes can I make to online accuracy closer to offline ?
toluwajosh commentedon Jul 11, 2016
@anujgupta82 the link you gave is broken. Can you please give another link that works. It will be highly appreciated. Thanks
BoltzmannBrain commentedon Jul 11, 2016
@ashwin123 would you be willing to share your code for this issue?
20 remaining items