Advanced Functional Prog.
Introduction
So, the "dot" product will simply corresponds to its mathematical definition:
let (<.>) xs ys = sum (xs <*> ys)
printfn "%A" ([1;2] <.> [3;4])
This one can next be used to model a single neuron with weights ws
:
let remind ws xs = ws <.> (1.0::xs)
let ws = [0.3;-0.5;0.1]
let xs = [1.0;1.0]
let y = 1.0
let y1 = remind ws xs
let e = y-y1
printfn "%A (%A)" y1 e (** -0.1 (1.1) **)
The learning algorithm has to reduce the e
rror between the desired output y
and the one returned by the network y1
, by adapting the weights ws
:
let k = 0.01
let ws1 = ws <+> (List.map (fun v->v*k*e) (1.0::xs))
let y2 = remind ws1 xs
let e1 = y-y2
7 - 9
advanced functional programming programmation fonctionnelle avancée dr mulhouse ensisa france thiry laurent uha fun fsharp
advanced functional programming programmation fonctionnelle avancée dr mulhouse ensisa france thiry laurent uha fun fsharp
advanced functional programming programmation fonctionnelle avancée dr mulhouse ensisa france thiry laurent uha fun fsharp
advanced functional programming programmation fonctionnelle avancée dr mulhouse ensisa france thiry laurent uha fun fsharp
advanced functional programming programmation fonctionnelle avancée dr mulhouse ensisa france thiry laurent uha fun fsharp
advanced functional programming programmation fonctionnelle avancée dr mulhouse ensisa france thiry laurent uha fun fsharp
advanced functional programming programmation fonctionnelle avancée dr mulhouse ensisa france thiry laurent uha fun fsharp
advanced functional programming programmation fonctionnelle avancée dr mulhouse ensisa france thiry laurent uha fun fsharp
advanced functional programming programmation fonctionnelle avancée dr mulhouse ensisa france thiry laurent uha fun fsharp
advanced functional programming programmation fonctionnelle avancée dr mulhouse ensisa france thiry laurent uha fun fsharp
advanced functional programming programmation fonctionnelle avancée dr mulhouse ensisa france thiry laurent uha fun fsharp