💣 Machine learning which might blow up in your face 💣

NoStarIsType and UndecidableInstances needed for ghc-8.6

NoStarIsType -- otherwise GHC gets confused about * as a type operator
import Data.Kind (Type) -- to replace the usage of * as a type
UndecidableInstances -- otherwise GHC complains about nested KnownNat (a * b)

authored by

Claude Heiland-Allen and committed by
Erik de Castro Lopo
0bc6bd5f 251a398a

+31 -8
+2
src/Grenade/Core/Shape.hs
··· 8 8 {-# LANGUAGE FlexibleContexts #-} 9 9 {-# LANGUAGE ScopedTypeVariables #-} 10 10 {-# LANGUAGE RankNTypes #-} 11 + {-# LANGUAGE NoStarIsType #-} 12 + {-# LANGUAGE UndecidableInstances #-} 11 13 {-| 12 14 Module : Grenade.Core.Shape 13 15 Description : Dependently typed shapes of data which are passed between layers of a network
+4 -1
src/Grenade/Layers/Concat.hs
··· 8 8 {-# LANGUAGE FlexibleInstances #-} 9 9 {-# LANGUAGE ScopedTypeVariables #-} 10 10 {-# LANGUAGE StandaloneDeriving #-} 11 + {-# LANGUAGE NoStarIsType #-} 12 + {-# LANGUAGE UndecidableInstances #-} 11 13 {-| 12 14 Module : Grenade.Layers.Concat 13 15 Description : Concatenation layer ··· 25 27 26 28 import Data.Singletons 27 29 import GHC.TypeLits 30 + import Data.Kind (Type) 28 31 29 32 import Grenade.Core 30 33 ··· 43 46 -- 44 47 -- 3D images become 3D images with more channels. The sizes must be the same, one can use Pad 45 48 -- and Crop layers to ensure this is the case. 46 - data Concat :: Shape -> * -> Shape -> * -> * where 49 + data Concat :: Shape -> Type -> Shape -> Type -> Type where 47 50 Concat :: x -> y -> Concat m x n y 48 51 49 52 instance (Show x, Show y) => Show (Concat m x n y) where
+5 -2
src/Grenade/Layers/Convolution.hs
··· 8 8 {-# LANGUAGE MultiParamTypeClasses #-} 9 9 {-# LANGUAGE FlexibleInstances #-} 10 10 {-# LANGUAGE FlexibleContexts #-} 11 + {-# LANGUAGE NoStarIsType #-} 12 + {-# LANGUAGE UndecidableInstances #-} 11 13 {-| 12 14 Module : Grenade.Layers.Convolution 13 15 Description : Convolution layer ··· 35 37 #else 36 38 import GHC.TypeLits 37 39 #endif 40 + import Data.Kind (Type) 38 41 39 42 import Numeric.LinearAlgebra hiding ( uniformSample, konst ) 40 43 import qualified Numeric.LinearAlgebra as LA ··· 61 64 -> Nat -- The number of column in the kernel filter 62 65 -> Nat -- The row stride of the convolution filter 63 66 -> Nat -- The columns stride of the convolution filter 64 - -> * where 67 + -> Type where 65 68 Convolution :: ( KnownNat channels 66 69 , KnownNat filters 67 70 , KnownNat kernelRows ··· 80 83 -> Nat -- The number of column in the kernel filter 81 84 -> Nat -- The row stride of the convolution filter 82 85 -> Nat -- The columns stride of the convolution filter 83 - -> * where 86 + -> Type where 84 87 Convolution' :: ( KnownNat channels 85 88 , KnownNat filters 86 89 , KnownNat kernelRows
+4 -1
src/Grenade/Layers/Crop.hs
··· 6 6 {-# LANGUAGE TypeFamilies #-} 7 7 {-# LANGUAGE FlexibleContexts #-} 8 8 {-# LANGUAGE MultiParamTypeClasses #-} 9 + {-# LANGUAGE NoStarIsType #-} 10 + {-# LANGUAGE UndecidableInstances #-} 9 11 {-| 10 12 Module : Grenade.Layers.Crop 11 13 Description : Cropping layer ··· 27 29 #else 28 30 import GHC.TypeLits 29 31 #endif 32 + import Data.Kind (Type) 30 33 31 34 import Grenade.Core 32 35 import Grenade.Layers.Internal.Pad ··· 38 41 data Crop :: Nat 39 42 -> Nat 40 43 -> Nat 41 - -> Nat -> * where 44 + -> Nat -> Type where 42 45 Crop :: Crop cropLeft cropTop cropRight cropBottom 43 46 44 47 instance Show (Crop cropLeft cropTop cropRight cropBottom) where
+5 -2
src/Grenade/Layers/Deconvolution.hs
··· 8 8 {-# LANGUAGE MultiParamTypeClasses #-} 9 9 {-# LANGUAGE FlexibleInstances #-} 10 10 {-# LANGUAGE FlexibleContexts #-} 11 + {-# LANGUAGE NoStarIsType #-} 12 + {-# LANGUAGE UndecidableInstances #-} 11 13 {-| 12 14 Module : Grenade.Layers.Deconvolution 13 15 Description : Deconvolution layer ··· 39 41 #else 40 42 import GHC.TypeLits 41 43 #endif 44 + import Data.Kind (Type) 42 45 43 46 import Numeric.LinearAlgebra hiding ( uniformSample, konst ) 44 47 import qualified Numeric.LinearAlgebra as LA ··· 60 63 -> Nat -- The number of column in the kernel filter 61 64 -> Nat -- The row stride of the Deconvolution filter 62 65 -> Nat -- The columns stride of the Deconvolution filter 63 - -> * where 66 + -> Type where 64 67 Deconvolution :: ( KnownNat channels 65 68 , KnownNat filters 66 69 , KnownNat kernelRows ··· 79 82 -> Nat -- The number of column in the kernel filter 80 83 -> Nat -- The row stride of the Deconvolution filter 81 84 -> Nat -- The columns stride of the Deconvolution filter 82 - -> * where 85 + -> Type where 83 86 Deconvolution' :: ( KnownNat channels 84 87 , KnownNat filters 85 88 , KnownNat kernelRows
+4 -1
src/Grenade/Layers/Pad.hs
··· 6 6 {-# LANGUAGE TypeFamilies #-} 7 7 {-# LANGUAGE MultiParamTypeClasses #-} 8 8 {-# LANGUAGE FlexibleContexts #-} 9 + {-# LANGUAGE NoStarIsType #-} 10 + {-# LANGUAGE UndecidableInstances #-} 9 11 {-| 10 12 Module : Grenade.Core.Pad 11 13 Description : Padding layer for 2D and 3D images ··· 27 29 #else 28 30 import GHC.TypeLits 29 31 #endif 32 + import Data.Kind (Type) 30 33 31 34 import Grenade.Core 32 35 import Grenade.Layers.Internal.Pad ··· 40 43 data Pad :: Nat 41 44 -> Nat 42 45 -> Nat 43 - -> Nat -> * where 46 + -> Nat -> Type where 44 47 Pad :: Pad padLeft padTop padRight padBottom 45 48 46 49 instance Show (Pad padLeft padTop padRight padBottom) where
+4 -1
src/Grenade/Layers/Pooling.hs
··· 7 7 {-# LANGUAGE TypeFamilies #-} 8 8 {-# LANGUAGE MultiParamTypeClasses #-} 9 9 {-# LANGUAGE FlexibleContexts #-} 10 + {-# LANGUAGE NoStarIsType #-} 11 + {-# LANGUAGE UndecidableInstances #-} 10 12 {-| 11 13 Module : Grenade.Core.Pooling 12 14 Description : Max Pooling layer for 2D and 3D images ··· 28 30 #else 29 31 import GHC.TypeLits 30 32 #endif 33 + import Data.Kind (Type) 31 34 32 35 import Grenade.Core 33 36 import Grenade.Layers.Internal.Pooling ··· 42 45 -- The kernel size dictates which input and output sizes will "fit". Fitting the equation: 43 46 -- `out = (in - kernel) / stride + 1` for both dimensions. 44 47 -- 45 - data Pooling :: Nat -> Nat -> Nat -> Nat -> * where 48 + data Pooling :: Nat -> Nat -> Nat -> Nat -> Type where 46 49 Pooling :: Pooling kernelRows kernelColumns strideRows strideColumns 47 50 48 51 instance Show (Pooling k k' s s') where
+2
src/Grenade/Layers/Reshape.hs
··· 3 3 {-# LANGUAGE TypeFamilies #-} 4 4 {-# LANGUAGE MultiParamTypeClasses #-} 5 5 {-# LANGUAGE FlexibleContexts #-} 6 + {-# LANGUAGE NoStarIsType #-} 7 + {-# LANGUAGE UndecidableInstances #-} 6 8 {-| 7 9 Module : Grenade.Layers.Reshape 8 10 Description : Multipurpose reshaping layer
+1
src/Grenade/Recurrent/Layers/ConcatRecurrent.hs
··· 8 8 {-# LANGUAGE FlexibleInstances #-} 9 9 {-# LANGUAGE ScopedTypeVariables #-} 10 10 {-# LANGUAGE StandaloneDeriving #-} 11 + {-# LANGUAGE UndecidableInstances #-} 11 12 {-| 12 13 Module : Grenade.Layers.Concat 13 14 Description : Concatenation layer