From e1826a4c5975260c784d3f6c43fd53a7092d64e4 Mon Sep 17 00:00:00 2001 From: Miguel Date: Fri, 22 Mar 2019 20:11:55 +0100 Subject: hoooray. fixed stupid bug. now at least 90% MNIST after one epoch --- mnist/Neuronet.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'mnist/Neuronet.hs') diff --git a/mnist/Neuronet.hs b/mnist/Neuronet.hs index 517f3b8..e3344c7 100644 --- a/mnist/Neuronet.hs +++ b/mnist/Neuronet.hs @@ -2,10 +2,12 @@ N E U R O T I C U S - A small and straight forward neural network coded in Haskell - from scratch. It uses gradient descent and the beatuiful + A small and straightforward neural network coded in Haskell + from scratch. It uses gradient descent and the beauty of backpropagation for learning. + TODOS: improve performance, parallelize, CUDA, FFI + Michal Idziorek March 2019 @@ -17,6 +19,9 @@ module Neuronet ,train -- train with one sample ,trainBatch -- train with batch ,asknet -- ask the neuroal net + + ,wghtact + ,backprop )where import Numeric.LinearAlgebra (Matrix,Vector,tr,scale,cmap,(#>),randn,toList,fromList,toLists,fromLists,Container) @@ -83,6 +88,7 @@ trainBatch r net xs ys = zipWith (upd r) net bp fc v a = zipWith ff v a ff (a,b) (c,d) = (a+c,b+d) --- | Update a Layer given the `direction` and `training rate` +-- | Update a single Layer given the `direction` and `training rate` upd :: Double -> Layer -> (Matrix Double,Vector Double) -> Layer upd r (a,b) (c,d) = (a-scale r c,b-scale r d) + -- cgit v1.2.3