on master help sign in
Docs
commitadf731218cd6e997da2936193a25f8647bf4c449 authorHuw Campbell <huw.campbell@ambiata.com> dateMon 10 Apr 2017, 12:06 (10 years ago) parentf4e1f28
10 files changed+79−5
src/Grenade.hs+1−1 src/Grenade/Layers/Elu.hs+7 src/Grenade/Layers/Logit.hs+8 src/Grenade/Layers/Pad.hs+9 src/Grenade/Layers/Pooling.hs+8 src/Grenade/Layers/Relu.hs+7 src/Grenade/Layers/Reshape.hs+10−3 src/Grenade/Layers/Softmax.hs+11 src/Grenade/Layers/Tanh.hs+7 src/Grenade/Layers/Trivial.hs+11−1
src/Grenade.hs+1−1
@@ -46,7 +46,7 @@ is a simple example which runs a logistic regression.
4646> randomMyNet = randomNetwork
4747
4848The function `randomMyNet` witnesses the `CreatableNetwork`
49−constraint of the neural network, that is, it ensures the network
49+constraint of the neural network, and in doing so, ensures the network
5050can be built, and hence, that the architecture is sound.
5151-}
5252
src/Grenade/Layers/Elu.hs+7
@@ -2,6 +2,13 @@
22{-# LANGUAGE TypeOperators #-}
33{-# LANGUAGE TypeFamilies #-}
44{-# LANGUAGE MultiParamTypeClasses #-}
5+{-|
6+Module : Grenade.Layers.Logit
7+Description : Exponential linear unit layer
8+Copyright : (c) Huw Campbell, 2016-2017
9+License : BSD2
10+Stability : experimental
11+-}
512module Grenade.Layers.Elu (
613 Elu (..)
714 ) where
src/Grenade/Layers/Logit.hs+8
@@ -3,6 +3,13 @@
33{-# LANGUAGE TypeFamilies #-}
44{-# LANGUAGE FlexibleInstances #-}
55{-# LANGUAGE MultiParamTypeClasses #-}
6+{-|
7+Module : Grenade.Layers.Logit
8+Description : Sigmoid nonlinear layer
9+Copyright : (c) Huw Campbell, 2016-2017
10+License : BSD2
11+Stability : experimental
12+-}
613module Grenade.Layers.Logit (
714 Logit (..)
815 ) where
@@ -14,6 +21,7 @@ import Data.Singletons
1421import Grenade.Core
1522
1623-- | A Logit layer.
24+--
1725-- A layer which can act between any shape of the same dimension, perfoming an sigmoid function.
1826-- This layer should be used as the output layer of a network for logistic regression (classification)
1927-- problems.
src/Grenade/Layers/Pad.hs+9
@@ -5,6 +5,13 @@
55{-# LANGUAGE TypeFamilies #-}
66{-# LANGUAGE MultiParamTypeClasses #-}
77{-# LANGUAGE FlexibleContexts #-}
8+{-|
9+Module : Grenade.Core.Pad
10+Description : Padding layer for 2D and 3D images
11+Copyright : (c) Huw Campbell, 2016-2017
12+License : BSD2
13+Stability : experimental
14+-}
815module Grenade.Layers.Pad (
916 Pad (..)
1017 ) where
@@ -22,6 +29,8 @@ import Numeric.LinearAlgebra (konst, subMatrix, diagBlock)
2229import Numeric.LinearAlgebra.Static (extract, create)
2330
2431-- | A padding layer for a neural network.
32+--
33+-- Pads on the X and Y dimension of an image.
2534data Pad :: Nat
2635 -> Nat
2736 -> Nat
src/Grenade/Layers/Pooling.hs+8
@@ -6,6 +6,13 @@
66{-# LANGUAGE TypeFamilies #-}
77{-# LANGUAGE MultiParamTypeClasses #-}
88{-# LANGUAGE FlexibleContexts #-}
9+{-|
10+Module : Grenade.Core.Pooling
11+Description : Max Pooling layer for 2D and 3D images
12+Copyright : (c) Huw Campbell, 2016-2017
13+License : BSD2
14+Stability : experimental
15+-}
916module Grenade.Layers.Pooling (
1017 Pooling (..)
1118 ) where
@@ -22,6 +29,7 @@ import Grenade.Layers.Internal.Pooling
2229import Numeric.LinearAlgebra.Static as LAS hiding ((|||), build, toRows)
2330
2431-- | A pooling layer for a neural network.
32+--
2533-- Does a max pooling, looking over a kernel similarly to the convolution network, but returning
2634-- maxarg only. This layer is often used to provide minor amounts of translational invariance.
2735--
src/Grenade/Layers/Relu.hs+7
@@ -2,6 +2,13 @@
22{-# LANGUAGE TypeOperators #-}
33{-# LANGUAGE TypeFamilies #-}
44{-# LANGUAGE MultiParamTypeClasses #-}
5+{-|
6+Module : Grenade.Layers.Relu
7+Description : Rectifying linear unit layer
8+Copyright : (c) Huw Campbell, 2016-2017
9+License : BSD2
10+Stability : experimental
11+-}
512module Grenade.Layers.Relu (
613 Relu (..)
714 ) where
src/Grenade/Layers/Reshape.hs+10−3
@@ -3,6 +3,13 @@
33{-# LANGUAGE TypeFamilies #-}
44{-# LANGUAGE MultiParamTypeClasses #-}
55{-# LANGUAGE FlexibleContexts #-}
6+{-|
7+Module : Grenade.Layers.Reshape
8+Description : Multipurpose reshaping layer
9+Copyright : (c) Huw Campbell, 2016-2017
10+License : BSD2
11+Stability : experimental
12+-}
613module Grenade.Layers.Reshape (
714 Reshape (..)
815 ) where
@@ -19,9 +26,9 @@ import Grenade.Core
1926
2027-- | Reshape Layer
2128--
22−-- Flattens input down to D1 from either 2D or 3D data.
23−--
24−-- Casts input D1 up to either 2D or 3D data if the shapes are good.
29+-- The Reshape layer can flatten any 2D or 3D image to 1D vector with the
30+-- same number of activations, as well as cast up from 1D to a 2D or 3D
31+-- shape.
2532--
2633-- Can also be used to turn a 3D image with only one channel into a 2D image
2734-- or vice versa.
src/Grenade/Layers/Softmax.hs+11
@@ -3,6 +3,13 @@
33{-# LANGUAGE TypeFamilies #-}
44{-# LANGUAGE FlexibleInstances #-}
55{-# LANGUAGE MultiParamTypeClasses #-}
6+{-|
7+Module : Grenade.Core.Softmax
8+Description : Softmax loss layer
9+Copyright : (c) Huw Campbell, 2016-2017
10+License : BSD2
11+Stability : experimental
12+-}
613module Grenade.Layers.Softmax (
714 Softmax (..)
815 , softmax
@@ -17,8 +24,12 @@ import Grenade.Core
1724import Numeric.LinearAlgebra.Static as LAS
1825
1926-- | A Softmax layer
27+--
2028-- This layer is like a logit layer, but normalises
2129-- a set of matricies to be probabilities.
30+--
31+-- One can use this layer as the last layer in a network
32+-- if they need normalised probabilities.
2233data Softmax = Softmax
2334 deriving Show
2435
src/Grenade/Layers/Tanh.hs+7
@@ -3,6 +3,13 @@
33{-# LANGUAGE TypeFamilies #-}
44{-# LANGUAGE FlexibleInstances #-}
55{-# LANGUAGE MultiParamTypeClasses #-}
6+{-|
7+Module : Grenade.Layers.Tanh
8+Description : Hyperbolic tangent nonlinear layer
9+Copyright : (c) Huw Campbell, 2016-2017
10+License : BSD2
11+Stability : experimental
12+-}
613module Grenade.Layers.Tanh (
714 Tanh (..)
815 ) where
src/Grenade/Layers/Trivial.hs+11−1
@@ -3,6 +3,13 @@
33{-# LANGUAGE TypeFamilies #-}
44{-# LANGUAGE MultiParamTypeClasses #-}
55{-# LANGUAGE FlexibleInstances #-}
6+{-|
7+Module : Grenade.Core.Trivial
8+Description : Trivial layer which perfoms no operations on the data
9+Copyright : (c) Huw Campbell, 2016-2017
10+License : BSD2
11+Stability : experimental
12+-}
613module Grenade.Layers.Trivial (
714 Trivial (..)
815 ) where
@@ -11,7 +18,10 @@ import Data.Serialize
1118
1219import Grenade.Core
1320
14−-- | A trivial layer.
21+-- | A Trivial layer.
22+--
23+-- This can be used to pass an unchanged value up one side of a
24+-- graph, for a Residual network for example.
1525data Trivial = Trivial
1626 deriving Show
1727