Updated to lts-20.18

This commit is contained in:
iko 2023-04-22 18:02:24 +03:00 committed by Erik de Castro Lopo
parent 3b6391877c
commit 0e01175386
20 changed files with 46 additions and 102 deletions

View File

@ -26,7 +26,7 @@ executable feedforward
, bytestring , bytestring
, cereal , cereal
, either , either
, optparse-applicative >= 0.13 && < 0.17 , optparse-applicative >= 0.13 && < 0.18
, text == 1.2.* , text == 1.2.*
, mtl >= 2.2.1 && < 2.3 , mtl >= 2.2.1 && < 2.3
, hmatrix , hmatrix
@ -42,7 +42,7 @@ executable mnist
, grenade , grenade
, attoparsec , attoparsec
, either , either
, optparse-applicative >= 0.13 && < 0.17 , optparse-applicative >= 0.13 && < 0.18
, text == 1.2.* , text == 1.2.*
, mtl >= 2.2.1 && < 2.3 , mtl >= 2.2.1 && < 2.3
, hmatrix >= 0.18 && < 0.21 , hmatrix >= 0.18 && < 0.21
@ -61,7 +61,7 @@ executable gan-mnist
, bytestring , bytestring
, cereal , cereal
, either , either
, optparse-applicative >= 0.13 && < 0.17 , optparse-applicative >= 0.13 && < 0.18
, text == 1.2.* , text == 1.2.*
, mtl >= 2.2.1 && < 2.3 , mtl >= 2.2.1 && < 2.3
, hmatrix >= 0.18 && < 0.21 , hmatrix >= 0.18 && < 0.21
@ -78,7 +78,7 @@ executable recurrent
, grenade , grenade
, attoparsec , attoparsec
, either , either
, optparse-applicative >= 0.13 && < 0.17 , optparse-applicative >= 0.13 && < 0.18
, text == 1.2.* , text == 1.2.*
, mtl >= 2.2.1 && < 2.3 , mtl >= 2.2.1 && < 2.3
, hmatrix >= 0.18 && < 0.21 , hmatrix >= 0.18 && < 0.21
@ -96,13 +96,14 @@ executable shakespeare
, bytestring , bytestring
, cereal , cereal
, either , either
, optparse-applicative >= 0.13 && < 0.17 , optparse-applicative >= 0.13 && < 0.18
, text == 1.2.* , text == 1.2.*
, mtl >= 2.2.1 && < 2.3 , mtl >= 2.2.1 && < 2.3
, hmatrix >= 0.18 && < 0.21 , hmatrix >= 0.18 && < 0.21
, transformers , transformers
, semigroups , semigroups
, singletons , singletons
, singletons-base
, vector , vector
, MonadRandom , MonadRandom
, containers , containers

View File

@ -14,22 +14,15 @@ import Data.Char ( isUpper, toUpper, toLower )
import Data.List ( foldl' ) import Data.List ( foldl' )
import Data.Maybe ( fromMaybe ) import Data.Maybe ( fromMaybe )
#if ! MIN_VERSION_base(4,13,0)
import Data.Semigroup ( (<>) )
#endif
import qualified Data.Vector as V import qualified Data.Vector as V
import Data.Vector ( Vector ) import Data.Vector ( Vector )
import qualified Data.Map as M import qualified Data.Map as M
#if ! MIN_VERSION_base(4,13,0)
import Data.Proxy ( Proxy (..) )
#endif
import qualified Data.ByteString as B import qualified Data.ByteString as B
import Data.Serialize import Data.Serialize
import Data.Singletons.Prelude
import GHC.TypeLits import GHC.TypeLits
import Numeric.LinearAlgebra.Static ( konst ) import Numeric.LinearAlgebra.Static ( konst )
@ -41,6 +34,8 @@ import Grenade.Recurrent
import Grenade.Utils.OneHot import Grenade.Utils.OneHot
import System.IO.Unsafe ( unsafeInterleaveIO ) import System.IO.Unsafe ( unsafeInterleaveIO )
import Data.Proxy
import Prelude.Singletons
-- The defininition for our natural language recurrent network. -- The defininition for our natural language recurrent network.
-- This network is able to learn and generate simple words in -- This network is able to learn and generate simple words in

View File

@ -38,7 +38,7 @@ source-repository head
library library
build-depends: build-depends:
base >= 4.8 && < 5 base >= 4.8 && < 5
, bytestring == 0.10.* , bytestring >= 0.10.0
, containers >= 0.5 && < 0.7 , containers >= 0.5 && < 0.7
, cereal >= 0.5 && < 0.6 , cereal >= 0.5 && < 0.6
, deepseq >= 1.4 && < 1.5 , deepseq >= 1.4 && < 1.5
@ -48,6 +48,7 @@ library
-- Versions of singletons are *tightly* coupled with the -- Versions of singletons are *tightly* coupled with the
-- GHC version so its fine to drop version bounds. -- GHC version so its fine to drop version bounds.
, singletons , singletons
, singletons-base
, vector >= 0.11 && < 0.13 , vector >= 0.11 && < 0.13
ghc-options: ghc-options:

View File

@ -34,7 +34,6 @@ module Grenade.Core.Network (
import Control.Monad.Random ( MonadRandom ) import Control.Monad.Random ( MonadRandom )
import Data.Singletons import Data.Singletons
import Data.Singletons.Prelude
import Data.Serialize import Data.Serialize
#if MIN_VERSION_base(4,9,0) #if MIN_VERSION_base(4,9,0)
@ -44,6 +43,7 @@ import Data.Kind (Type)
import Grenade.Core.Layer import Grenade.Core.Layer
import Grenade.Core.LearningParameters import Grenade.Core.LearningParameters
import Grenade.Core.Shape import Grenade.Core.Shape
import Prelude.Singletons
-- | Type of a network. -- | Type of a network.
-- --

View File

@ -13,11 +13,12 @@ module Grenade.Core.Runner (
, runNet , runNet
) where ) where
import Data.Singletons.Prelude
import Grenade.Core.LearningParameters import Grenade.Core.LearningParameters
import Grenade.Core.Network import Grenade.Core.Network
import Grenade.Core.Shape import Grenade.Core.Shape
import Data.Singletons
import Prelude.Singletons
-- | Perform reverse automatic differentiation on the network -- | Perform reverse automatic differentiation on the network
-- for the current input and expected output. -- for the current input and expected output.

View File

@ -21,35 +21,20 @@ Stability : experimental
module Grenade.Core.Shape ( module Grenade.Core.Shape (
S (..) S (..)
, Shape (..) , Shape (..)
#if MIN_VERSION_singletons(2,6,0)
, SShape (..) , SShape (..)
#else
, Sing (..)
#endif
, randomOfShape , randomOfShape
, fromStorable , fromStorable
) where ) where
import Control.DeepSeq (NFData (..)) import Control.DeepSeq (NFData (..))
import Control.Monad.Random ( MonadRandom, getRandom ) import Control.Monad.Random ( MonadRandom, getRandom )
#if MIN_VERSION_base(4,13,0)
import Data.Kind (Type) import Data.Kind (Type)
#endif
import Data.Proxy import Data.Proxy
import Data.Serialize import Data.Serialize
import Data.Singletons import Data.Singletons
import Data.Singletons.TypeLits
import Data.Vector.Storable ( Vector ) import Data.Vector.Storable ( Vector )
import qualified Data.Vector.Storable as V import qualified Data.Vector.Storable as V
#if MIN_VERSION_base(4,11,0)
import GHC.TypeLits hiding (natVal)
#else
import GHC.TypeLits import GHC.TypeLits
#endif
import qualified Numeric.LinearAlgebra.Static as H import qualified Numeric.LinearAlgebra.Static as H
import Numeric.LinearAlgebra.Static import Numeric.LinearAlgebra.Static
import qualified Numeric.LinearAlgebra as NLA import qualified Numeric.LinearAlgebra as NLA
@ -99,9 +84,9 @@ deriving instance Show (S n)
type instance Sing = SShape type instance Sing = SShape
data SShape :: Shape -> Type where data SShape :: Shape -> Type where
D1Sing :: Sing a -> SShape ('D1 a) D1Sing :: KnownNat a => SShape ('D1 a)
D2Sing :: Sing a -> Sing b -> SShape ('D2 a b) D2Sing :: (KnownNat a, KnownNat b) => SShape ('D2 a b)
D3Sing :: KnownNat (a * c) => Sing a -> Sing b -> Sing c -> SShape ('D3 a b c) D3Sing :: (KnownNat (a * c), KnownNat a, KnownNat b, KnownNat c) => SShape ('D3 a b c)
#else #else
data instance Sing (n :: Shape) where data instance Sing (n :: Shape) where
D1Sing :: Sing a -> Sing ('D1 a) D1Sing :: Sing a -> Sing ('D1 a)
@ -110,11 +95,11 @@ data instance Sing (n :: Shape) where
#endif #endif
instance KnownNat a => SingI ('D1 a) where instance KnownNat a => SingI ('D1 a) where
sing = D1Sing sing sing = D1Sing
instance (KnownNat a, KnownNat b) => SingI ('D2 a b) where instance (KnownNat a, KnownNat b) => SingI ('D2 a b) where
sing = D2Sing sing sing sing = D2Sing
instance (KnownNat a, KnownNat b, KnownNat c, KnownNat (a * c)) => SingI ('D3 a b c) where instance (KnownNat a, KnownNat b, KnownNat c, KnownNat (a * c)) => SingI ('D3 a b c) where
sing = D3Sing sing sing sing sing = D3Sing
instance SingI x => Num (S x) where instance SingI x => Num (S x) where
(+) = n2 (+) (+) = n2 (+)
@ -163,13 +148,13 @@ randomOfShape :: forall x m. ( MonadRandom m, SingI x ) => m (S x)
randomOfShape = do randomOfShape = do
seed :: Int <- getRandom seed :: Int <- getRandom
return $ case (sing :: Sing x) of return $ case (sing :: Sing x) of
D1Sing SNat -> D1Sing ->
S1D (randomVector seed Uniform * 2 - 1) S1D (randomVector seed Uniform * 2 - 1)
D2Sing SNat SNat -> D2Sing ->
S2D (uniformSample seed (-1) 1) S2D (uniformSample seed (-1) 1)
D3Sing SNat SNat SNat -> D3Sing ->
S3D (uniformSample seed (-1) 1) S3D (uniformSample seed (-1) 1)
-- | Generate a shape from a Storable Vector. -- | Generate a shape from a Storable Vector.
@ -177,13 +162,13 @@ randomOfShape = do
-- Returns Nothing if the vector is of the wrong size. -- Returns Nothing if the vector is of the wrong size.
fromStorable :: forall x. SingI x => Vector Double -> Maybe (S x) fromStorable :: forall x. SingI x => Vector Double -> Maybe (S x)
fromStorable xs = case sing :: Sing x of fromStorable xs = case sing :: Sing x of
D1Sing SNat -> D1Sing ->
S1D <$> H.create xs S1D <$> H.create xs
D2Sing SNat SNat -> D2Sing ->
S2D <$> mkL xs S2D <$> mkL xs
D3Sing SNat SNat SNat -> D3Sing ->
S3D <$> mkL xs S3D <$> mkL xs
where where
mkL :: forall rows columns. (KnownNat rows, KnownNat columns) mkL :: forall rows columns. (KnownNat rows, KnownNat columns)
@ -220,13 +205,13 @@ n2 f (S2D x) (S2D y) = S2D (f x y)
n2 f (S3D x) (S3D y) = S3D (f x y) n2 f (S3D x) (S3D y) = S3D (f x y)
-- Helper function for creating the number instances -- Helper function for creating the number instances
nk :: forall x. SingI x => Double -> S x nk :: forall x. (SingI x) => Double -> S x
nk x = case (sing :: Sing x) of nk x = case (sing :: Sing x) of
D1Sing SNat -> D1Sing ->
S1D (konst x) S1D (konst x)
D2Sing SNat SNat -> D2Sing ->
S2D (konst x) S2D (konst x)
D3Sing SNat SNat SNat -> D3Sing ->
S3D (konst x) S3D (konst x)

View File

@ -28,16 +28,9 @@ import Control.Monad.Random hiding ( fromList )
import Data.Maybe import Data.Maybe
import Data.Proxy import Data.Proxy
import Data.Serialize import Data.Serialize
import Data.Singletons.TypeLits
#if MIN_VERSION_base(4,11,0)
import GHC.TypeLits hiding (natVal)
#else
import GHC.TypeLits import GHC.TypeLits
#endif
#if MIN_VERSION_base(4,9,0)
import Data.Kind (Type) import Data.Kind (Type)
#endif
import Numeric.LinearAlgebra hiding ( uniformSample, konst ) import Numeric.LinearAlgebra hiding ( uniformSample, konst )
import qualified Numeric.LinearAlgebra as LA import qualified Numeric.LinearAlgebra as LA

View File

@ -21,16 +21,9 @@ module Grenade.Layers.Crop (
import Data.Maybe import Data.Maybe
import Data.Proxy import Data.Proxy
import Data.Serialize import Data.Serialize
import Data.Singletons.TypeLits
#if MIN_VERSION_base(4,11,0)
import GHC.TypeLits hiding (natVal)
#else
import GHC.TypeLits import GHC.TypeLits
#endif
#if MIN_VERSION_base(4,9,0)
import Data.Kind (Type) import Data.Kind (Type)
#endif
import Grenade.Core import Grenade.Core
import Grenade.Layers.Internal.Pad import Grenade.Layers.Internal.Pad

View File

@ -32,16 +32,9 @@ import Control.Monad.Random hiding ( fromList )
import Data.Maybe import Data.Maybe
import Data.Proxy import Data.Proxy
import Data.Serialize import Data.Serialize
import Data.Singletons.TypeLits
#if MIN_VERSION_base(4,11,0)
import GHC.TypeLits hiding (natVal)
#else
import GHC.TypeLits import GHC.TypeLits
#endif
#if MIN_VERSION_base(4,9,0)
import Data.Kind (Type) import Data.Kind (Type)
#endif
import Numeric.LinearAlgebra hiding ( uniformSample, konst ) import Numeric.LinearAlgebra hiding ( uniformSample, konst )
import qualified Numeric.LinearAlgebra as LA import qualified Numeric.LinearAlgebra as LA

View File

@ -13,7 +13,6 @@ import Control.Monad.Random hiding (fromList)
import Data.Proxy import Data.Proxy
import Data.Serialize import Data.Serialize
import Data.Singletons.TypeLits
import qualified Numeric.LinearAlgebra as LA import qualified Numeric.LinearAlgebra as LA
import Numeric.LinearAlgebra.Static import Numeric.LinearAlgebra.Static
@ -21,6 +20,7 @@ import Numeric.LinearAlgebra.Static
import Grenade.Core import Grenade.Core
import Grenade.Layers.Internal.Update import Grenade.Layers.Internal.Update
import GHC.TypeLits
-- | A basic fully connected (or inner product) neural network layer. -- | A basic fully connected (or inner product) neural network layer.
data FullyConnected i o = FullyConnected data FullyConnected i o = FullyConnected

View File

@ -21,16 +21,9 @@ module Grenade.Layers.Pad (
import Data.Maybe import Data.Maybe
import Data.Proxy import Data.Proxy
import Data.Serialize import Data.Serialize
import Data.Singletons.TypeLits
#if MIN_VERSION_base(4,11,0)
import GHC.TypeLits hiding (natVal)
#else
import GHC.TypeLits import GHC.TypeLits
#endif
#if MIN_VERSION_base(4,9,0)
import Data.Kind (Type) import Data.Kind (Type)
#endif
import Grenade.Core import Grenade.Core
import Grenade.Layers.Internal.Pad import Grenade.Layers.Internal.Pad

View File

@ -22,16 +22,9 @@ module Grenade.Layers.Pooling (
import Data.Maybe import Data.Maybe
import Data.Proxy import Data.Proxy
import Data.Serialize import Data.Serialize
import Data.Singletons.TypeLits
#if MIN_VERSION_base(4,11,0)
import GHC.TypeLits hiding (natVal)
#else
import GHC.TypeLits import GHC.TypeLits
#endif
#if MIN_VERSION_base(4,9,0)
import Data.Kind (Type) import Data.Kind (Type)
#endif
import Grenade.Core import Grenade.Core
import Grenade.Layers.Internal.Pooling import Grenade.Layers.Internal.Pooling

View File

@ -17,7 +17,6 @@ module Grenade.Layers.Reshape (
import Data.Serialize import Data.Serialize
import Data.Singletons.TypeLits
import GHC.TypeLits import GHC.TypeLits
import Numeric.LinearAlgebra.Static import Numeric.LinearAlgebra.Static

View File

@ -29,16 +29,13 @@ module Grenade.Recurrent.Core.Network (
import Control.Monad.Random ( MonadRandom ) import Control.Monad.Random ( MonadRandom )
import Data.Singletons ( SingI )
import Data.Singletons.Prelude ( Head, Last )
import Data.Serialize import Data.Serialize
#if MIN_VERSION_base(4,9,0)
import Data.Kind (Type) import Data.Kind (Type)
#endif
import Grenade.Core import Grenade.Core
import Grenade.Recurrent.Core.Layer import Grenade.Recurrent.Core.Layer
import Prelude.Singletons
-- | Witness type to say indicate we're building up with a normal feed -- | Witness type to say indicate we're building up with a normal feed
-- forward layer. -- forward layer.

View File

@ -17,10 +17,10 @@ module Grenade.Recurrent.Core.Runner (
) where ) where
import Data.List ( foldl' ) import Data.List ( foldl' )
import Data.Singletons.Prelude
import Grenade.Core import Grenade.Core
import Grenade.Recurrent.Core.Network import Grenade.Recurrent.Core.Network
import Prelude.Singletons
type RecurrentGradients layers = [RecurrentGradient layers] type RecurrentGradients layers = [RecurrentGradient layers]

View File

@ -16,11 +16,8 @@ module Grenade.Recurrent.Layers.BasicRecurrent (
import Control.Monad.Random ( MonadRandom, getRandom ) import Control.Monad.Random ( MonadRandom, getRandom )
import Data.Singletons.TypeLits
#if MIN_VERSION_base(4,9,0)
import Data.Kind (Type) import Data.Kind (Type)
#endif
import Numeric.LinearAlgebra.Static import Numeric.LinearAlgebra.Static

View File

@ -21,11 +21,7 @@ import Control.Monad.Random ( MonadRandom, getRandom )
-- import Data.List ( foldl1' ) -- import Data.List ( foldl1' )
import Data.Proxy import Data.Proxy
import Data.Serialize import Data.Serialize
import Data.Singletons.TypeLits
#if MIN_VERSION_base(4,9,0)
import Data.Kind (Type) import Data.Kind (Type)
#endif
import qualified Numeric.LinearAlgebra as LA import qualified Numeric.LinearAlgebra as LA
import Numeric.LinearAlgebra.Static import Numeric.LinearAlgebra.Static
@ -33,6 +29,7 @@ import Numeric.LinearAlgebra.Static
import Grenade.Core import Grenade.Core
import Grenade.Recurrent.Core import Grenade.Recurrent.Core
import Grenade.Layers.Internal.Update import Grenade.Layers.Internal.Update
import GHC.TypeLits
-- | Long Short Term Memory Recurrent unit -- | Long Short Term Memory Recurrent unit

View File

@ -22,7 +22,6 @@ import Data.Map ( Map )
import qualified Data.Map as M import qualified Data.Map as M
import Data.Proxy import Data.Proxy
import Data.Singletons.TypeLits
import Data.Vector ( Vector ) import Data.Vector ( Vector )
import qualified Data.Vector as V import qualified Data.Vector as V
@ -31,6 +30,7 @@ import qualified Data.Vector.Storable as VS
import Numeric.LinearAlgebra ( maxIndex ) import Numeric.LinearAlgebra ( maxIndex )
import Numeric.LinearAlgebra.Devel import Numeric.LinearAlgebra.Devel
import Numeric.LinearAlgebra.Static import Numeric.LinearAlgebra.Static
import GHC.TypeLits
import Grenade.Core.Shape import Grenade.Core.Shape

View File

@ -20,7 +20,7 @@
# #
# resolver: ./custom-snapshot.yaml # resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-18.28 resolver: lts-20.18
# User packages to be built. # User packages to be built.
# Various formats can be used as shown in the example below. # Various formats can be used as shown in the example below.
@ -70,3 +70,9 @@ extra-deps:
# #
# Allow a newer minor version of GHC than the snapshot specifies # Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor # compiler-check: newer-minor
nix:
enable: true
packages:
- blas
- lapack

View File

@ -7,13 +7,13 @@ packages:
- completed: - completed:
hackage: typelits-witnesses-0.3.0.3@sha256:2d9df4ac6ff3077bfd2bf659e4b495e157723ac5b45c519762853f55df5c16db,2738 hackage: typelits-witnesses-0.3.0.3@sha256:2d9df4ac6ff3077bfd2bf659e4b495e157723ac5b45c519762853f55df5c16db,2738
pantry-tree: pantry-tree:
size: 469
sha256: 6a42a462f98e94933b6e9721acd912c6c6b6a4743635efd15cc5871908c816a0 sha256: 6a42a462f98e94933b6e9721acd912c6c6b6a4743635efd15cc5871908c816a0
size: 469
original: original:
hackage: typelits-witnesses-0.3.0.3 hackage: typelits-witnesses-0.3.0.3
snapshots: snapshots:
- completed: - completed:
size: 590100 sha256: 9fa4bece7acfac1fc7930c5d6e24606004b09e80aa0e52e9f68b148201008db9
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/28.yaml size: 649606
sha256: 428ec8d5ce932190d3cbe266b9eb3c175cd81e984babf876b64019e2cbe4ea68 url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/18.yaml
original: lts-18.28 original: lts-20.18