on master help sign in
Docs
adf7312Huw Campbell
src/Grenade.hs+1−1
@@ -46,7 +46,7 @@ is a simple example which runs a logistic regression.
46> randomMyNet = randomNetwork
46> randomMyNet = randomNetwork
47
47
48The function `randomMyNet` witnesses the `CreatableNetwork`
48The 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
50can be built, and hence, that the architecture is sound.
50can be built, and hence, that the architecture is sound.
51-}
51-}
52
52
src/Grenade/Layers/Elu.hs+7
@@ -2,6 +2,13 @@
2{-# LANGUAGE TypeOperators #-}
2{-# LANGUAGE TypeOperators #-}
3{-# LANGUAGE TypeFamilies #-}
3{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE MultiParamTypeClasses #-}
4{-# 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+-}
5module Grenade.Layers.Elu (
12module Grenade.Layers.Elu (
6 Elu (..)
13 Elu (..)
7 ) where
14 ) where
src/Grenade/Layers/Logit.hs+8
@@ -3,6 +3,13 @@
3{-# LANGUAGE TypeFamilies #-}
3{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE MultiParamTypeClasses #-}
5{-# 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+-}
6module Grenade.Layers.Logit (
13module Grenade.Layers.Logit (
7 Logit (..)
14 Logit (..)
8 ) where
15 ) where
@@ -14,6 +21,7 @@ import Data.Singletons
14import Grenade.Core
21import Grenade.Core
15
22
16-- | A Logit layer.
23-- | A Logit layer.
24+--
17-- A layer which can act between any shape of the same dimension, perfoming an sigmoid function.
25-- A layer which can act between any shape of the same dimension, perfoming an sigmoid function.
18-- This layer should be used as the output layer of a network for logistic regression (classification)
26-- This layer should be used as the output layer of a network for logistic regression (classification)
19-- problems.
27-- problems.
src/Grenade/Layers/Pad.hs+9
@@ -5,6 +5,13 @@
5{-# LANGUAGE TypeFamilies #-}
5{-# LANGUAGE TypeFamilies #-}
6{-# LANGUAGE MultiParamTypeClasses #-}
6{-# LANGUAGE MultiParamTypeClasses #-}
7{-# LANGUAGE FlexibleContexts #-}
7{-# 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+-}
8module Grenade.Layers.Pad (
15module Grenade.Layers.Pad (
9 Pad (..)
16 Pad (..)
10 ) where
17 ) where
@@ -22,6 +29,8 @@ import Numeric.LinearAlgebra (konst, subMatrix, diagBlock)
22import Numeric.LinearAlgebra.Static (extract, create)
29import Numeric.LinearAlgebra.Static (extract, create)
23
30
24-- | A padding layer for a neural network.
31-- | A padding layer for a neural network.
32+--
33+-- Pads on the X and Y dimension of an image.
25data Pad :: Nat
34data Pad :: Nat
26 -> Nat
35 -> Nat
27 -> Nat
36 -> Nat
src/Grenade/Layers/Pooling.hs+8
@@ -6,6 +6,13 @@
6{-# LANGUAGE TypeFamilies #-}
6{-# LANGUAGE TypeFamilies #-}
7{-# LANGUAGE MultiParamTypeClasses #-}
7{-# LANGUAGE MultiParamTypeClasses #-}
8{-# LANGUAGE FlexibleContexts #-}
8{-# 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+-}
9module Grenade.Layers.Pooling (
16module Grenade.Layers.Pooling (
10 Pooling (..)
17 Pooling (..)
11 ) where
18 ) where
@@ -22,6 +29,7 @@ import Grenade.Layers.Internal.Pooling
22import Numeric.LinearAlgebra.Static as LAS hiding ((|||), build, toRows)
29import Numeric.LinearAlgebra.Static as LAS hiding ((|||), build, toRows)
23
30
24-- | A pooling layer for a neural network.
31-- | A pooling layer for a neural network.
32+--
25-- Does a max pooling, looking over a kernel similarly to the convolution network, but returning
33-- Does a max pooling, looking over a kernel similarly to the convolution network, but returning
26-- maxarg only. This layer is often used to provide minor amounts of translational invariance.
34-- maxarg only. This layer is often used to provide minor amounts of translational invariance.
27--
35--
src/Grenade/Layers/Relu.hs+7
@@ -2,6 +2,13 @@
2{-# LANGUAGE TypeOperators #-}
2{-# LANGUAGE TypeOperators #-}
3{-# LANGUAGE TypeFamilies #-}
3{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE MultiParamTypeClasses #-}
4{-# 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+-}
5module Grenade.Layers.Relu (
12module Grenade.Layers.Relu (
6 Relu (..)
13 Relu (..)
7 ) where
14 ) where
src/Grenade/Layers/Reshape.hs+10−3
@@ -3,6 +3,13 @@
3{-# LANGUAGE TypeFamilies #-}
3{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE MultiParamTypeClasses #-}
4{-# LANGUAGE MultiParamTypeClasses #-}
5{-# LANGUAGE FlexibleContexts #-}
5{-# 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+-}
6module Grenade.Layers.Reshape (
13module Grenade.Layers.Reshape (
7 Reshape (..)
14 Reshape (..)
8 ) where
15 ) where
@@ -19,9 +26,9 @@ import Grenade.Core
19
26
20-- | Reshape Layer
27-- | Reshape Layer
21--
28--
22−-- Flattens input down to D1 from either 2D or 3D data.
29+-- The Reshape layer can flatten any 2D or 3D image to 1D vector with the
23−--
30+-- same number of activations, as well as cast up from 1D to a 2D or 3D
24−-- Casts input D1 up to either 2D or 3D data if the shapes are good.
31+-- shape.
25--
32--
26-- Can also be used to turn a 3D image with only one channel into a 2D image
33-- Can also be used to turn a 3D image with only one channel into a 2D image
27-- or vice versa.
34-- or vice versa.
src/Grenade/Layers/Softmax.hs+11
@@ -3,6 +3,13 @@
3{-# LANGUAGE TypeFamilies #-}
3{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE MultiParamTypeClasses #-}
5{-# 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+-}
6module Grenade.Layers.Softmax (
13module Grenade.Layers.Softmax (
7 Softmax (..)
14 Softmax (..)
8 , softmax
15 , softmax
@@ -17,8 +24,12 @@ import Grenade.Core
17import Numeric.LinearAlgebra.Static as LAS
24import Numeric.LinearAlgebra.Static as LAS
18
25
19-- | A Softmax layer
26-- | A Softmax layer
27+--
20-- This layer is like a logit layer, but normalises
28-- This layer is like a logit layer, but normalises
21-- a set of matricies to be probabilities.
29-- 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.
22data Softmax = Softmax
33data Softmax = Softmax
23 deriving Show
34 deriving Show
24
35
src/Grenade/Layers/Tanh.hs+7
@@ -3,6 +3,13 @@
3{-# LANGUAGE TypeFamilies #-}
3{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE FlexibleInstances #-}
5{-# LANGUAGE MultiParamTypeClasses #-}
5{-# 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+-}
6module Grenade.Layers.Tanh (
13module Grenade.Layers.Tanh (
7 Tanh (..)
14 Tanh (..)
8 ) where
15 ) where
src/Grenade/Layers/Trivial.hs+11−1
@@ -3,6 +3,13 @@
3{-# LANGUAGE TypeFamilies #-}
3{-# LANGUAGE TypeFamilies #-}
4{-# LANGUAGE MultiParamTypeClasses #-}
4{-# LANGUAGE MultiParamTypeClasses #-}
5{-# LANGUAGE FlexibleInstances #-}
5{-# 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+-}
6module Grenade.Layers.Trivial (
13module Grenade.Layers.Trivial (
7 Trivial (..)
14 Trivial (..)
8 ) where
15 ) where
@@ -11,7 +18,10 @@ import Data.Serialize
11
18
12import Grenade.Core
19import Grenade.Core
13
20
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.
15data Trivial = Trivial
25data Trivial = Trivial
16 deriving Show
26 deriving Show
17
27