Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package next
- class Neuron(size: Int) {
- var spin: Double = 1.0
- var weights: DoubleArray = DoubleArray(size, { _ -> 0.0})
- var bias: Int = 0
- fun updateSpin(spins: List<Double>): Boolean {
- val value: Double = weights.indices.sumByDouble { weights[it] * spins[it] + bias }
- val oldSpin = spin
- spin = if (value >= 0) 1.0 else -1.0
- return spin != oldSpin
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement