tangled
alpha
login
or
join now
huwcampbell.com
/
grenade
1
fork
atom
💣 Machine learning which might blow up in your face 💣
1
fork
atom
overview
issues
pulls
pipelines
Drop support for GHC < 8.0
Erik de Castro Lopo
6 years ago
fed6eb2c
bf6ddad6
+6
-26
4 changed files
expand all
collapse all
unified
split
examples
main
recurrent.hs
test
Test
Grenade
Layers
PadCrop.hs
Network.hs
Hedgehog
TypeLits.hs
-4
examples/main/recurrent.hs
···
9
9
import Control.Monad ( foldM )
10
10
import Control.Monad.Random ( MonadRandom, getRandomR )
11
11
12
12
-
#if __GLASGOW_HASKELL__ < 800
13
13
-
import Data.List ( unfoldr )
14
14
-
#else
15
12
import Data.List ( cycle, unfoldr )
16
16
-
#endif
17
13
import Data.Semigroup ( (<>) )
18
14
19
15
import qualified Numeric.LinearAlgebra.Static as SA
-4
test/Test/Grenade/Layers/PadCrop.hs
···
7
7
{-# LANGUAGE ScopedTypeVariables #-}
8
8
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
9
9
10
10
-
#if __GLASGOW_HASKELL__ < 800
11
11
-
{-# OPTIONS_GHC -fno-warn-incomplete-patterns #-}
12
12
-
#endif
13
13
-
14
10
module Test.Grenade.Layers.PadCrop where
15
11
16
12
import Grenade
-3
test/Test/Grenade/Network.hs
···
14
14
import Control.Monad.ST ( runST )
15
15
16
16
import Data.Constraint
17
17
-
#if __GLASGOW_HASKELL__ < 800
18
18
-
import Data.Proxy
19
19
-
#endif
20
17
import qualified Data.Vector.Storable as VS
21
18
import qualified Data.Vector.Storable.Mutable as VS ( write )
22
19
import Data.Singletons
+6
-15
test/Test/Hedgehog/TypeLits.hs
···
8
8
module Test.Hedgehog.TypeLits where
9
9
10
10
import Data.Constraint
11
11
-
#if __GLASGOW_HASKELL__ < 800
12
12
-
import Data.Proxy
13
13
-
#endif
14
11
import Data.Singletons
15
12
16
13
import Hedgehog (Gen)
···
19
16
import Grenade
20
17
21
18
import GHC.TypeLits
22
22
-
import GHC.TypeLits.Witnesses
19
19
+
import GHC.TypeLits.Witnesses hiding (SNat)
23
20
import Test.Hedgehog.Compat
24
21
25
22
genNat :: Gen SomeNat
···
27
24
~(Just n) <- someNatVal <$> choose 1 10
28
25
return n
29
26
30
30
-
#if __GLASGOW_HASKELL__ < 800
31
31
-
type Shape' = ('KProxy :: KProxy Shape)
32
32
-
#else
33
33
-
type Shape' = Shape
34
34
-
#endif
35
35
-
36
36
-
genShape :: Gen (SomeSing Shape')
27
27
+
genShape :: Gen (SomeSing Shape)
37
28
genShape
38
29
= Gen.choice [
39
30
genD1
···
41
32
, genD3
42
33
]
43
34
44
44
-
genD1 :: Gen (SomeSing Shape')
35
35
+
genD1 :: Gen (SomeSing Shape)
45
36
genD1 = do
46
37
n <- genNat
47
38
return $ case n of
48
39
SomeNat (_ :: Proxy x) -> SomeSing (sing :: Sing ('D1 x))
49
40
50
50
-
genD2 :: Gen (SomeSing Shape')
41
41
+
genD2 :: Gen (SomeSing Shape)
51
42
genD2 = do
52
43
n <- genNat
53
44
m <- genNat
54
45
return $ case (n, m) of
55
46
(SomeNat (_ :: Proxy x), SomeNat (_ :: Proxy y)) -> SomeSing (sing :: Sing ('D2 x y))
56
47
57
57
-
genD3 :: Gen (SomeSing Shape')
48
48
+
genD3 :: Gen (SomeSing Shape)
58
49
genD3 = do
59
50
n <- genNat
60
51
m <- genNat
···
64
55
case natDict px %* natDict pz of
65
56
Dict -> SomeSing (sing :: Sing ('D3 x y z))
66
57
67
67
-
rss :: SomeSing Shape' -> String
58
58
+
rss :: SomeSing Shape -> String
68
59
rss (SomeSing (r :: Sing s)) = case r of
69
60
(D1Sing a@SNat) -> "D1 " ++ show (natVal a)
70
61
(D2Sing a@SNat b@SNat) -> "D2 " ++ show (natVal a) ++ " " ++ show (natVal b)