Browse Source

reordered inputs and improved style

master
erichhasl 8 years ago
parent
commit
5913326a24
1 changed files with 7 additions and 5 deletions
  1. +7
    -5
      Network.hs

+ 7
- 5
Network.hs View File

@@ -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.
(-->) :: 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


Loading…
Cancel
Save