Advertisement
bartoshr

You know the wee

Jan 16th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.41 KB | None | 0 0
  1. package next
  2.  
  3. class Neuron(size: Int) {
  4.  
  5.     var spin: Double = 1.0
  6.     var weights: DoubleArray = DoubleArray(size, { _ -> 0.0})
  7.     var bias: Int = 0
  8.  
  9.     fun updateSpin(spins: List<Double>): Boolean {
  10.         val value: Double = weights.indices.sumByDouble { weights[it] * spins[it] + bias }
  11.         val oldSpin = spin
  12.         spin = if (value >= 0) 1.0 else -1.0
  13.         return spin != oldSpin
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement