@@ -32,18 +32,20 @@ import Data.Singletons ( SingI )
32import Data.Singletons.Prelude ( Head, Last )
32import Data.Singletons.Prelude ( Head, Last )
33import Data.Serialize
33import Data.Serialize
35+import Data.Kind (Type)
35import Grenade.Core
37import Grenade.Core
36import Grenade.Recurrent.Core.Layer
38import Grenade.Recurrent.Core.Layer
38-- | Witness type to say indicate we're building up with a normal feed
40-- | Witness type to say indicate we're building up with a normal feed
39-- forward layer.
41-- forward layer.
40−data FeedForward :: * -> *
42+data FeedForward :: Type -> Type
41-- | Witness type to say indicate we're building up with a recurrent layer.
43-- | Witness type to say indicate we're building up with a recurrent layer.
42−data Recurrent :: * -> *
44+data Recurrent :: Type -> Type
44-- | Type of a recurrent neural network.
46-- | Type of a recurrent neural network.
46−-- The [*] type specifies the types of the layers.
48+-- The [Type] type specifies the types of the layers.
48-- The [Shape] type specifies the shapes of data passed between the layers.
50-- The [Shape] type specifies the shapes of data passed between the layers.
@@ -52,7 +54,7 @@ data Recurrent :: * -> *
53-- Often, to make the definitions more concise, one will use a type alias
55-- Often, to make the definitions more concise, one will use a type alias
54-- for these empty data types.
56-- for these empty data types.
55−data RecurrentNetwork :: [*] -> [Shape] -> * where
57+data RecurrentNetwork :: [Type] -> [Shape] -> Type where
56 RNil :: SingI i
58 RNil :: SingI i
57 => RecurrentNetwork '[] '[i]
59 => RecurrentNetwork '[] '[i]
@@ -71,7 +73,7 @@ infixr 5 :~@>
71-- | Gradient of a network.
73-- | Gradient of a network.
73-- Parameterised on the layers of the network.
75-- Parameterised on the layers of the network.
74−data RecurrentGradient :: [*] -> * where
76+data RecurrentGradient :: [Type] -> Type where
75 RGNil :: RecurrentGradient '[]
77 RGNil :: RecurrentGradient '[]
77 (://>) :: UpdateLayer x
79 (://>) :: UpdateLayer x
@@ -81,7 +83,7 @@ data RecurrentGradient :: [*] -> * where
82-- | Recurrent inputs (sideways shapes on an imaginary unrolled graph)
84-- | Recurrent inputs (sideways shapes on an imaginary unrolled graph)
83-- Parameterised on the layers of a Network.
85-- Parameterised on the layers of a Network.
84−data RecurrentInputs :: [*] -> * where
86+data RecurrentInputs :: [Type] -> Type where
85 RINil :: RecurrentInputs '[]
87 RINil :: RecurrentInputs '[]
87 (:~~+>) :: (UpdateLayer x, Fractional (RecurrentInputs xs))
89 (:~~+>) :: (UpdateLayer x, Fractional (RecurrentInputs xs))
@@ -95,7 +97,7 @@ data RecurrentInputs :: [*] -> * where
96-- We index on the time step length as well, to ensure
98-- We index on the time step length as well, to ensure
97-- that that all Tape lengths are the same.
99-- that that all Tape lengths are the same.
98−data RecurrentTape :: [*] -> [Shape] -> * where
100+data RecurrentTape :: [Type] -> [Shape] -> Type where
99 TRNil :: SingI i
101 TRNil :: SingI i
100 => RecurrentTape '[] '[i]
102 => RecurrentTape '[] '[i]
@@ -204,7 +206,7 @@ instance (Show x, Show (RecurrentNetwork xs rs)) => Show (RecurrentNetwork (Recu
205-- | A network can easily be created by hand with (:~~>) and (:~@>), but an easy way to initialise a random
207-- | A network can easily be created by hand with (:~~>) and (:~@>), but an easy way to initialise a random
206-- recurrent network and a set of random inputs for it is with the randomRecurrent.
208-- recurrent network and a set of random inputs for it is with the randomRecurrent.
207−class CreatableRecurrent (xs :: [*]) (ss :: [Shape]) where
209+class CreatableRecurrent (xs :: [Type]) (ss :: [Shape]) where
208 -- | Create a network of the types requested
210 -- | Create a network of the types requested
209 randomRecurrent :: MonadRandom m => m (RecurrentNetwork xs ss)
211 randomRecurrent :: MonadRandom m => m (RecurrentNetwork xs ss)