By stone
Follow these steps:
$ npm install neuron-fiber --save
const Perceptron = require('neuron-fiber')
/**
* input
*/
const x = [
[0, 0, 1, 0],
[0, 1, 1, 0],
[1, 0, 1, 0],
[1, 1, 1, 0]
]
/**
* output
*/
const y = [
[0],
[0],
[1],
[1]
]
/**
* training times
*/
const times = 1000
/**
* data ready to predict result
*/
const data=[[1, 1, 1, 1]]
/**
* begin to train 1000 times
*/
const neuron = new Perceptron(x, y, times)
/**
* result is predicted
*/
const result = neuron.predict(data)
- 权重更新算法 W(j)=W(j)+delta W(j)
- delata W(j)= 学习率 n _ (Y-Y')_ .X(j)
- 学习率 由 derivSigmoid() 来构建 , 为 sigmoid 的倒数,即斜率