gpt4 book ai didi

javascript - brain.js 神经网络的正确训练

转载 作者:行者123 更新时间:2023-11-29 10:29:11 26 4
gpt4 key购买 nike

我显然误解了 brain.js instructions on training 中的某些内容

我玩过这个 repl.it code

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 }

我做错了什么?

最佳答案

增加迭代次数和降低错误阈值对我有用:

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 }

关于javascript - brain.js 神经网络的正确训练,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50894323/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com