reordered inputs and improved style
This commit is contained in:
+6
-5
@@ -39,19 +39,19 @@ module Network (
|
|||||||
loadNetwork
|
loadNetwork
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.List.Split (chunksOf)
|
|
||||||
import Data.List (foldl')
|
import Data.List (foldl')
|
||||||
import Data.Binary
|
import Data.List.Split (chunksOf)
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
import Text.Read (readMaybe)
|
import Text.Read (readMaybe)
|
||||||
|
import Data.Binary
|
||||||
|
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import System.Random
|
import System.Random
|
||||||
import Control.Monad (zipWithM, forM)
|
import Control.Monad (zipWithM, forM)
|
||||||
import Data.Array.IO
|
import Data.Array.IO
|
||||||
import Debug.Trace (trace)
|
import Debug.Trace (trace)
|
||||||
import Text.Regex.PCRE
|
|
||||||
|
|
||||||
|
import Text.Regex.PCRE
|
||||||
import Numeric.LinearAlgebra
|
import Numeric.LinearAlgebra
|
||||||
|
|
||||||
-- | The generic feedforward network type, a binary instance is implemented.
|
-- | 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
|
-- | A list of 'Sample's
|
||||||
type Samples a = [Sample a]
|
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
|
(-->) :: Vector a -> Vector a -> Sample a
|
||||||
(-->) = (,)
|
(-->) = (,)
|
||||||
|
|
||||||
@@ -139,7 +140,7 @@ newNetwork layerSizes
|
|||||||
return $ Network lays
|
return $ Network lays
|
||||||
where go :: Int -> Int -> IO (Layer Double)
|
where go :: Int -> Int -> IO (Layer Double)
|
||||||
go inputSize outputSize = do
|
go inputSize outputSize = do
|
||||||
ws <- fmap (/ (sqrt $ fromIntegral inputSize)) (randn outputSize inputSize)
|
ws <- (/ (sqrt $ fromIntegral inputSize)) <$> randn outputSize inputSize
|
||||||
seed <- randomIO
|
seed <- randomIO
|
||||||
let bs = randomVector seed Gaussian outputSize
|
let bs = randomVector seed Gaussian outputSize
|
||||||
return $ Layer ws bs
|
return $ Layer ws bs
|
||||||
|
|||||||
Reference in New Issue
Block a user