From 5913326a2408a94e4b261a6af28e9df248a5e68a Mon Sep 17 00:00:00 2001 From: erichhasl Date: Mon, 28 Aug 2017 09:30:39 +0200 Subject: [PATCH] reordered inputs and improved style --- Network.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Network.hs b/Network.hs index a3aaf65..39f4ddf 100644 --- a/Network.hs +++ b/Network.hs @@ -18,7 +18,7 @@ module Network ( Layer(..), newNetwork, output, - + -- * Learning functions trainShuffled, trainNTimes, @@ -39,19 +39,19 @@ module Network ( loadNetwork ) where -import Data.List.Split (chunksOf) import Data.List (foldl') -import Data.Binary +import Data.List.Split (chunksOf) import Data.Maybe (fromMaybe) import Text.Read (readMaybe) +import Data.Binary import System.Directory import System.Random import Control.Monad (zipWithM, forM) import Data.Array.IO import Debug.Trace (trace) -import Text.Regex.PCRE +import Text.Regex.PCRE import Numeric.LinearAlgebra -- | The generic feedforward network type, a binary instance is implemented. @@ -109,7 +109,8 @@ type Sample a = (Vector a, Vector a) -- | A list of 'Sample's type Samples a = [Sample a] --- | A simple synonym for the (,) operator, used to create samples very intuitively. +-- | A simple synonym for the (,) operator, used to create samples very +-- intuitively. (-->) :: Vector a -> Vector a -> Sample a (-->) = (,) @@ -139,7 +140,7 @@ newNetwork layerSizes return $ Network lays where go :: Int -> Int -> IO (Layer Double) go inputSize outputSize = do - ws <- fmap (/ (sqrt $ fromIntegral inputSize)) (randn outputSize inputSize) + ws <- (/ (sqrt $ fromIntegral inputSize)) <$> randn outputSize inputSize seed <- randomIO let bs = randomVector seed Gaussian outputSize return $ Layer ws bs