youyuge34 / cosine_stateful_lstm Goto Github PK
View Code? Open in Web Editor NEW有关keras中stateful LSTM模型讲解的配套代码
有关keras中stateful LSTM模型讲解的配套代码
运行这个notebook,预测值会逐渐小于 -4,跟你的运行结果差别很大。你再调试下?
你好,我对你代码中训练数据的产生方式有疑问。我理解的是:
stateful的LSTM需要训练数据的每个样本按顺序是能够衔接上的。
比如原始数据为:
p0,p1,p2,p3,p4,p5,p6......pn
那么在样本划分的时候需要timestep(你的代码中的look_back)和划分步长相等,比如look_back=3时,是这样:
sample1 x:[p0,p1,p2],y:[p3]
sample2 x:[p3,p4,p5],y:[p6]
sample3 x:[p6,p7,p8],y:[p9]
......
look_back=5时,是这样:
sample1 x:[p0,p1,p2,p3,p4],y:[p5]
sample2 x:[p5,p6,p7,p8,p9],y:[p10]
sample3 x:[p10,p11,p12,p13,p14],y:[p15]
......
这样state才能在一个fit中按原来的顺序传递。
既然想要上一个序列样本LSTM的状态传递到下一个序列样本,为什么还要使用model.reset_state()重置模型中所有层的状态,这样岂不是又变成了stateless?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.