在brain.js页面上,有一个简单的LSTMTimeStep示例-https://github.com/BrainJS/brain.js
var net = new brain.recurrent.LSTMTimeStep();
net.train([
[1, 3],
[2, 2],
[3, 1],
]);
var output = net.run([[1, 3], [2, 2]]); // [3, 1]
这足以预测下一个值/标签。但是,如果我有成千上万的训练集和成千上万的测试数据集,并且我想预测下一个10或100个值,该怎么办?该怎么做?
答案 0 :(得分:1)
我认为您需要使用预测方法才能预测一组值。
使用参数计数。
在此处检查预测部分:
[https://github.com/BrainJS/brain.js#for-training-with-rnntimestep-lstmtimestep-and-grutimestep][1]
我做了一个例子,看起来很正常
const net = new brain.recurrent.LSTMTimeStep({
inputSize: 3,
hiddenLayers: [10],
outputSize: 3
});
//Same test as previous, but combined on a single set
const trainingData = [
[8,8,1],[8,8,3],[8,8,5],[8,2,8],[3,6,6],[8,4,5]
];
net.train(trainingData, { log: true, iterations:200 });
console.log( net.run([[8,2,3]]));
console.log( net.forecast([[8,8,2]], 7)) ;
在下面您可以看到结果:
iterations: 0, training error: 14.974015071677664
iterations: 10, training error: 4.263545592625936
iterations: 20, training error: 4.1400322914123535
iterations: 30, training error: 4.106281439463298
iterations: 40, training error: 4.019651651382446
iterations: 50, training error: 3.9397279421488443
iterations: 60, training error: 3.7364938259124756
iterations: 70, training error: 3.594826857248942
iterations: 80, training error: 3.4333037535349527
iterations: 90, training error: 3.2692082722981772
iterations: 100, training error: 3.0003069241841636
iterations: 110, training error: 2.741880734761556
iterations: 120, training error: 2.559309403101603
iterations: 130, training error: 2.549466371536255
iterations: 140, training error: 2.165259758631388
iterations: 150, training error: 1.912764310836792
iterations: 160, training error: 1.7081804275512695
iterations: 170, training error: 1.5422560373942058
iterations: 180, training error: 1.3950440088907878
iterations: 190, training error: 1.2614964246749878
Float32Array [ 7.450448036193848, 7.630088806152344, 3.102810859680176 ]
[ Float32Array [ 7.769495010375977, 7.626269340515137, 3.01503324508667 ],
Float32Array [ 8.504044532775879, 7.038702011108398, 5.765346050262451 ],
Float32Array [ 7.573630332946777, 3.117426872253418, 8.106966018676758 ],
Float32Array [ 4.165530204772949, 5.516692161560059, 5.85803747177124 ],
Float32Array [ 6.954248428344727, 3.7581958770751953, 5.24238920211792 ],
Float32Array [ 5.5002217292785645, 4.540862560272217, 6.505147457122803 ],
Float32Array [ 6.376245498657227, 4.115119934082031, 5.876959323883057 ] ]
答案 1 :(得分:0)
您需要使用给定的集合进行训练,然后,如果需要,可以对接下来的10个项目进行以下操作: 预测下一项。 将其添加到训练集中。 预测下一个+1项。 将下一个+1添加到训练集中。
还阅读了有关github repo上的流的信息。我还建议您使用到目前为止已尝试过的内容来更新您的问题,这将有助于将来的用户进一步理解该问题,并添加到问题和答案中。