Last active
February 22, 2018 08:53
-
-
Save baofengyv/7b02ba35a18d62bd6d6694776f2ef23f to your computer and use it in GitHub Desktop.
神经元
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Neural { | |
constructor() { | |
this.id = Math.random(); | |
this.weightS = [1]; | |
} | |
setWeightS(newWeightS) { | |
this.weightS = newWeightS; | |
} | |
// 刺激神经元 | |
activate(input) { | |
return this.activation(input); | |
} | |
activation(input) { | |
let sum = .5; | |
for (let i = 0; i < input.length; i++) | |
sum += this.__FUNCTION_line_kx_12(input[i], this.weightS[i]); | |
return (sum > .5) * 1; | |
} | |
// 普通线性函数 | |
__FUNCTION_line_kx(input, weight) { | |
return input * weight; | |
} | |
// 恒过点(0.5,0.5) | |
__FUNCTION_line_kx_12(input, weight) { | |
return .5 - weight * (input - .5); | |
} | |
} | |
let x = new Neural; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment