浏览代码

reordered inputs and improved style

master
erichhasl 8 年前
父节点
当前提交
5913326a24
共有 1 个文件被更改,包括 7 次插入5 次删除
  1. +7
    -5
      Network.hs

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


正在加载...
取消
保存