cknd / pyESN

Echo State Networks in Python
MIT License
296 stars 122 forks source link

Add support for keras models for outputs #6

Open jonahweissman opened 6 years ago

jonahweissman commented 6 years ago

To follow up on #5, here's what I worked out: Keras layer building turned out to be too much of a challenge for me, so I modified pyESN to optionally accept a Keras model as an input. Now, instead of learning linear weights to map readouts to outputs, it trains the Keras model to do so. If you don't think that this is appropriate to be included in the main code, that's totally fine. I just wanted to share what I did.

Here's mackey.ipynb, modified to use my new functionality. The performance is worse, but it shows how it works. (GitHub won't let me upload .ipynb, so I changed the file extension to .txt. Just change it back to view.)

I added a new test, but it would only catch the most extreme errors. I wasn't sure of what to include in a more useful test. The freq_gen performance test fails both before and after my changes.

Also, I'd like to add a .gitignore. Should I open a new PR or can I just add it to this one?

jonahweissman commented 6 years ago

I fixed the bug that was causing the freq_gen performance bug. The activation function is applied to the data twice in ESN.predict; once while stepping through states and again to all the outputs before they are returned. I had gotten rid of the second time, but I've added it back in dd03086.