本文介绍了brain.js正确训练神经网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须清楚地误解了
我玩这个
const brain = require('brain.js');
const network = new brain.NeuralNetwork();
network.train([
{ input: { doseA: 0 }, output: { indicatorA: 0 } },
{ input: { doseA: 0.1 }, output: { indicatorA: 0.02 } },
{ input: { doseA: 0.2 }, output: { indicatorA: 0.04 } },
{ input: { doseA: 0.3 }, output: { indicatorA: 0.06 } },
{ input: { doseA: 0.4 }, output: { indicatorA: 0.08 } },
{ input: { doseA: 0.5 }, output: { indicatorA: 0.10 } },
{ input: { doseA: 0.6 }, output: { indicatorA: 0.12 } },
{ input: { doseA: 0.7 }, output: { indicatorA: 0.14 } },
]);
const result = network.run({ doseA: 0.35 });
console.log(result);
>> { indicatorA: 0.12165333330631256 }
=> undefined
期待结果为 {indicatorA:0.07}
我做错了什么?
推荐答案
增加迭代次数并降低错误阈值对我有用:
Increasing the number of iterations and decreasing the error threshold worked for me:
const brain = require('brain.js');
const network = new brain.NeuralNetwork();
network.train([
{ input: { doseA: 0 }, output: { indicatorA: 0 } },
{ input: { doseA: 0.1 }, output: { indicatorA: 0.02 } },
{ input: { doseA: 0.2 }, output: { indicatorA: 0.04 } },
{ input: { doseA: 0.3 }, output: { indicatorA: 0.06 } },
{ input: { doseA: 0.4 }, output: { indicatorA: 0.08 } },
{ input: { doseA: 0.5 }, output: { indicatorA: 0.10 } },
{ input: { doseA: 0.6 }, output: { indicatorA: 0.12 } },
{ input: { doseA: 0.7 }, output: { indicatorA: 0.14 } },
], {
log: true,
iterations: 1e6,
errorThresh: 0.00001
});
const result = network.run({ doseA: 0.35 });
console.log(result);
//
结果: {indicatorA:0.0693388432264328}
这篇关于brain.js正确训练神经网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!