Kar*_*son 5 javascript algorithm machine-learning
令人遗憾的是,LSTM RNN 没有一个简单的预测时间序列数据的简单例子.
https://github.com/cazala/synaptic
https://github.com/cazala/synaptic/wiki/Architect#lstm
我想使用以下数组中的历史数据:
const array = [
0,
0,
0,
1,
0,
0,
0,
1
];
Run Code Online (Sandbox Code Playgroud)
有些漂亮的心灵数据就在那里吗?
我想A)用数组训练算法然后B)使用以下数组测试算法:
const array = [
0,
0,
0,
1,
0,
0,
0,
1,
0
];
Run Code Online (Sandbox Code Playgroud)
应该导致它预测a 0
.
不幸的是,文档很糟糕,没有明确的代码示例.有人有任何例子吗?
这个答案不是用Synaptic写的,而是用Neataptic写的.我决定快速回答一下,我将很快将其纳入文档中.这是代码,它工作9/10次:
var network = new neataptic.architect.LSTM(1,6,1);
// when the timeseries is [0,0,0,1,0,0,0,1...]
var trainingData = [
{ input: [0], output: [0] },
{ input: [0], output: [0] },
{ input: [0], output: [1] },
{ input: [1], output: [0] },
{ input: [0], output: [0] },
{ input: [0], output: [0] },
{ input: [0], output: [1] },
];
network.train(trainingData, {
log: 500,
iterations: 6000,
error: 0.03,
clear: true,
rate: 0.05,
});
Run Code Online (Sandbox Code Playgroud)
在JSFIDDLE上运行它以查看预测!要获得更多预测,请打开此预测.
我做出的一些选择的解释:
~0.2