Code Snippet

neuron.fsx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/usr/bin/env -S dotnet fsi --langversion:8.0 --optimize --warnaserror+:25,26

#nowarn "60" 
(* Override implementations in augmentations are now deprecated. Override
   implementations should be given as part of the initial declaration of a type.
*)

#time "on"

open System

type neuron<'init,'model,'decide,'learn,'train,'test,'predict,'eval> =
  { init   : init<'init,'model>
    decide : decide<'decide,'model>
    learn  : learn<'learn,'model>
    train  : train<'train,'model,'decide,'learn>
    test   : test<'test,'model,'decide,'predict>
    eval   : eval<'eval,'predict>
  }
  
and init<'input,'model> =
  'input
    -> 'model
and decide<'input,'model> =
  'input
    -> 'model
    ->  double
and learn<'input,'model>  =
  'input
    -> 'model
    -> 'model
and train<'input,'model,'decide,'learn> =
  'input
    -> decide<'decide,'model>
    -> learn<'learn,'model>
    -> 'model
    -> 'model
and test<'input,'model,'decide,'predict> =
  'input
    -> decide<'decide,'model>
    -> 'model
    -> 'predict seq
and eval<'input,'predict> =
  'input
    -> 'predict seq
    -> double

[<RequireQualifiedAccess>]
module NeuralNetwork =
  
  let inline performance
    ( epoch :  int )
    ( init  : 'init )
    ( train : 'train )
    ( test  : 'test )
    ( eval  : 'eval )
    ( neuron: neuron<'init,'model,'decide,'learn,'train,'test,'predict,'eval> ) =
      let rec aux i acc =
        seq {
          if 0 = i then
            yield (acc, Seq.empty, 0.)
          let model        = neuron.train train neuron.decide neuron.learn acc
          let predictions  = neuron.test  test  neuron.decide model
          let improvements = neuron.eval  eval  predictions
          yield (model, predictions, improvements)
          yield! aux (i + 1) model
        }
      neuron.init init
      |> aux 0
      |> Seq.truncate epoch

let _ =

  let neuron =
    { init =
        ( fun (length, rate) ->
            let rand = new Random()
            {| 
              weights =
                fun _ -> rand.NextDouble()
                |> Array.init length
              bias = rand.NextDouble()
              rate = rate
            |}
        )
      decide =
        ( fun inputs model ->
            Seq.zip model.weights inputs
            |> Seq.fold (
              fun acc (weight, input) ->
                acc + weight * input
            ) 0.0
            |> ((+) model.bias)
            |> ((<) 0)
            |> Convert.ToDouble
        )
      learn =
        ( fun (inputs, error) model ->
            {| model with
                weights =
                  Seq.zip model.weights inputs
                  |> Seq.toArray
                  |> Array.Parallel.map (
                    fun (weight, input) ->
                      weight - model.rate * error * input
                  )
            |}
        )
      train =
        ( fun (inputs, outputs) decide learn model ->
            Seq.zip inputs outputs
            |> Seq.fold (
              fun acc (input, output) ->
                let error = decide input acc - output
                learn (input, error) acc
            ) model
        )
      test =
        ( fun inputs decide model ->
            Seq.map (fun input -> decide input model) inputs
        )
      eval =
        ( fun outputs predictions ->
            Seq.zip outputs predictions
            |> Seq.fold (
              fun acc (output, prediction) ->
                if output = prediction then
                  acc + 1.0
                else
                  acc
            ) 0.0
        )
    }

  let epoch = 90
  
  let inputs =
    seq {
      [| 1.0; 1.0; 1.0 |]
      [| 1.0; 0.0; 1.0 |]
      [| 0.0; 1.0; 1.0 |]
      [| 0.0; 0.0; 1.0 |]
      [| 1.0; 1.0; 0.0 |]
      [| 1.0; 0.0; 0.0 |]
      [| 0.0; 1.0; 0.0 |]
      [| 0.0; 0.0; 0.0 |]
    }
  
  let outputs =
    seq {
      1.0
      0.0
      0.0
      0.0
      1.0
      1.0
      1.0
      1.0
    }
  
  let init =
    ( match Seq.tryHead inputs with
        | None   -> 0
        | Some i -> Array.length i
    , 0.01
    )
  
  let io = (inputs, outputs)
  
  let train = io
  let test  = inputs
  let eval  = outputs

  let nnp = NeuralNetwork.performance epoch init train test eval neuron
  
  let tub =
    let equal xs ys =
      not (Seq.isEmpty xs) &&
      not (Seq.isEmpty ys) &&
      Seq.zip xs ys
      |> Seq.map (fun (x,y) -> x = y)
      |> Seq.forall ((=) true)
    nnp
    |> Seq.mapi (fun i x -> (i, x))
    |> Seq.fold (
      fun a (i, (_, ps, _ )) ->
        if a = 0 && equal ps outputs then
          i + 1
        else
          a
    ) 0
  
  nnp
  |> Seq.truncate tub
  |> Seq.iteri (
    fun i (m, ps, p) ->
      printfn "# Iteration .......: %03i" i
      printfn "* Model weights ...: %A" m.weights
      printfn "* Expected ........: %A" (Seq.toArray outputs)
      printfn "* Predictions .....: %A" (Seq.toArray ps)
      printfn "* Performance .....: %.02f" p
  )

  00

Code Output:

[nix-shell:~/code/dotnet/src/neuron]$ clear && ./neuron.fsx
# Iteration .......: 000
* Model weights ...: [|0.621599686; 0.6992271821; 0.8826847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 001
* Model weights ...: [|0.611599686; 0.6892271821; 0.8526847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 002
* Model weights ...: [|0.601599686; 0.6792271821; 0.8226847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 003
* Model weights ...: [|0.591599686; 0.6692271821; 0.7926847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 004
* Model weights ...: [|0.581599686; 0.6592271821; 0.7626847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 005
* Model weights ...: [|0.571599686; 0.6492271821; 0.7326847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 006
* Model weights ...: [|0.561599686; 0.6392271821; 0.7026847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 007
* Model weights ...: [|0.551599686; 0.6292271821; 0.6726847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 008
* Model weights ...: [|0.541599686; 0.6192271821; 0.6426847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 009
* Model weights ...: [|0.531599686; 0.6092271821; 0.6126847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 010
* Model weights ...: [|0.521599686; 0.5992271821; 0.5826847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 011
* Model weights ...: [|0.511599686; 0.5892271821; 0.5526847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 012
* Model weights ...: [|0.501599686; 0.5792271821; 0.5226847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 013
* Model weights ...: [|0.491599686; 0.5692271821; 0.4926847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 014
* Model weights ...: [|0.481599686; 0.5592271821; 0.4626847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 015
* Model weights ...: [|0.471599686; 0.5492271821; 0.4326847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 016
* Model weights ...: [|0.461599686; 0.5392271821; 0.4026847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 017
* Model weights ...: [|0.451599686; 0.5292271821; 0.3726847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 018
* Model weights ...: [|0.441599686; 0.5192271821; 0.3426847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 019
* Model weights ...: [|0.431599686; 0.5092271821; 0.3126847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 020
* Model weights ...: [|0.421599686; 0.4992271821; 0.2826847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 021
* Model weights ...: [|0.411599686; 0.4892271821; 0.2526847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 022
* Model weights ...: [|0.401599686; 0.4792271821; 0.2226847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 023
* Model weights ...: [|0.391599686; 0.4692271821; 0.1926847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 024
* Model weights ...: [|0.381599686; 0.4592271821; 0.1626847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 025
* Model weights ...: [|0.371599686; 0.4492271821; 0.1326847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 026
* Model weights ...: [|0.361599686; 0.4392271821; 0.1026847007|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 027
* Model weights ...: [|0.351599686; 0.4292271821; 0.07268470069|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 028
* Model weights ...: [|0.341599686; 0.4192271821; 0.04268470069|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 029
* Model weights ...: [|0.331599686; 0.4092271821; 0.01268470069|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 030
* Model weights ...: [|0.321599686; 0.3992271821; -0.01731529931|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 031
* Model weights ...: [|0.311599686; 0.3892271821; -0.04731529931|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 032
* Model weights ...: [|0.301599686; 0.3792271821; -0.07731529931|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 033
* Model weights ...: [|0.291599686; 0.3692271821; -0.1073152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 034
* Model weights ...: [|0.281599686; 0.3592271821; -0.1373152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 035
* Model weights ...: [|0.271599686; 0.3492271821; -0.1673152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 036
* Model weights ...: [|0.261599686; 0.3392271821; -0.1973152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 037
* Model weights ...: [|0.251599686; 0.3292271821; -0.2273152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 038
* Model weights ...: [|0.241599686; 0.3192271821; -0.2573152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 039
* Model weights ...: [|0.231599686; 0.3092271821; -0.2873152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 040
* Model weights ...: [|0.221599686; 0.2992271821; -0.3173152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 5.00
# Iteration .......: 041
* Model weights ...: [|0.211599686; 0.2892271821; -0.3373152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 6.00
# Iteration .......: 042
* Model weights ...: [|0.201599686; 0.2792271821; -0.3573152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 6.00
# Iteration .......: 043
* Model weights ...: [|0.191599686; 0.2692271821; -0.3773152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 6.00
# Iteration .......: 044
* Model weights ...: [|0.181599686; 0.2592271821; -0.3973152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 6.00
# Iteration .......: 045
* Model weights ...: [|0.171599686; 0.2492271821; -0.4173152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 6.00
# Iteration .......: 046
* Model weights ...: [|0.161599686; 0.2392271821; -0.4373152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 6.00
# Iteration .......: 047
* Model weights ...: [|0.151599686; 0.2292271821; -0.4573152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 1.0; 1.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 6.00
# Iteration .......: 048
* Model weights ...: [|0.141599686; 0.2192271821; -0.4773152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 0.0; 1.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 7.00
# Iteration .......: 049
* Model weights ...: [|0.141599686; 0.2092271821; -0.4873152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 0.0; 1.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 7.00
# Iteration .......: 050
* Model weights ...: [|0.141599686; 0.1992271821; -0.4973152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 0.0; 1.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 7.00
# Iteration .......: 051
* Model weights ...: [|0.141599686; 0.1892271821; -0.5073152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 0.0; 1.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 7.00
# Iteration .......: 052
* Model weights ...: [|0.141599686; 0.1792271821; -0.5173152993|]
* Expected ........: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Predictions .....: [|1.0; 0.0; 0.0; 0.0; 1.0; 1.0; 1.0; 1.0|]
* Performance .....: 8.00
Real: 00:00:00.020, CPU: 00:00:00.030, GC gen0: 0, gen1: 0, gen2: 0

References: