繁体   English   中英

brain.js正确训练神经网络

[英]brain.js correct training of the neuralNetwork

我必须清楚地误解了大脑中的某些内容.js关于训练的指示

我玩这个repl.it代码

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 }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM