packages feed

backprop 0.2.6.4 → 0.2.6.5

raw patch · 15 files changed

+52/−22 lines, 15 filesdep ~basedep ~vinylPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: base, vinyl

API changes (from Hackage documentation)

- Numeric.Backprop.Class: instance (Data.Vinyl.Core.ReifyConstraint Numeric.Backprop.Class.Backprop f rs, Data.Vinyl.Core.RMap rs, Data.Vinyl.Core.RApply rs, Data.Vinyl.Core.RecApplicative rs, Data.Vinyl.TypeLevel.NatToInt (Data.Vinyl.TypeLevel.RLength rs), Data.Vinyl.Core.RPureConstrained (Data.Vinyl.ARec.IndexableField rs) rs) => Numeric.Backprop.Class.Backprop (Data.Vinyl.ARec.ARec f rs)
- Numeric.Backprop.Class: instance Numeric.Backprop.Class.Backprop GHC.Integer.Type.Integer
- Numeric.Backprop.Class: instance Numeric.Backprop.Class.Backprop GHC.Natural.Natural
- Numeric.Backprop.Class: instance Numeric.Backprop.Class.Backprop a => Numeric.Backprop.Class.Backprop (Data.Semigroup.Option a)
- Numeric.Backprop.Explicit: instance (Data.Reflection.Reifies s Numeric.Backprop.Internal.W, Numeric.Backprop.Explicit.BVGroup s as i1 o1, Numeric.Backprop.Explicit.BVGroup s bs i2 o2, cs Data.Type.Equality.~ (as Data.Vinyl.TypeLevel.++ bs), Data.Vinyl.Core.RecApplicative as) => Numeric.Backprop.Explicit.BVGroup s (i1 () : i2 () : cs) (i1 GHC.Generics.:*: i2) (o1 GHC.Generics.:*: o2)
- Numeric.Backprop.Explicit: instance (Data.Reflection.Reifies s Numeric.Backprop.Internal.W, Numeric.Backprop.Explicit.BVGroup s as i1 o1, Numeric.Backprop.Explicit.BVGroup s bs i2 o2, cs Data.Type.Equality.~ (as Data.Vinyl.TypeLevel.++ bs), Data.Vinyl.Core.RecApplicative as) => Numeric.Backprop.Explicit.BVGroup s (i1 () : i2 () : cs) (i1 GHC.Generics.:+: i2) (o1 GHC.Generics.:+: o2)
- Numeric.Backprop.Op: data Rec (a :: u -> Type) (b :: [u]) :: forall u. () => u -> Type -> [u] -> Type
+ Numeric.Backprop.Class: instance (Data.Vinyl.Core.ReifyConstraint Numeric.Backprop.Class.Backprop f rs, Data.Vinyl.Core.RMap rs, Data.Vinyl.Core.RApply rs, Data.Vinyl.Core.RecApplicative rs, Data.Vinyl.TypeLevel.NatToInt (Data.Vinyl.TypeLevel.RLength rs), Data.Vinyl.Core.RPureConstrained (Data.Vinyl.ARec.Internal.IndexableField rs) rs, Data.Vinyl.ARec.Internal.ToARec rs) => Numeric.Backprop.Class.Backprop (Data.Vinyl.ARec.Internal.ARec f rs)
+ Numeric.Backprop.Class: instance Numeric.Backprop.Class.Backprop GHC.Num.Integer.Integer
+ Numeric.Backprop.Class: instance Numeric.Backprop.Class.Backprop GHC.Num.Natural.Natural
+ Numeric.Backprop.Explicit: instance (Data.Reflection.Reifies s Numeric.Backprop.Internal.W, Numeric.Backprop.Explicit.BVGroup s as i1 o1, Numeric.Backprop.Explicit.BVGroup s bs i2 o2, cs GHC.Types.~ (as Data.Vinyl.TypeLevel.++ bs), Data.Vinyl.Core.RecApplicative as) => Numeric.Backprop.Explicit.BVGroup s (i1 () : i2 () : cs) (i1 GHC.Generics.:*: i2) (o1 GHC.Generics.:*: o2)
+ Numeric.Backprop.Explicit: instance (Data.Reflection.Reifies s Numeric.Backprop.Internal.W, Numeric.Backprop.Explicit.BVGroup s as i1 o1, Numeric.Backprop.Explicit.BVGroup s bs i2 o2, cs GHC.Types.~ (as Data.Vinyl.TypeLevel.++ bs), Data.Vinyl.Core.RecApplicative as) => Numeric.Backprop.Explicit.BVGroup s (i1 () : i2 () : cs) (i1 GHC.Generics.:+: i2) (o1 GHC.Generics.:+: o2)
+ Numeric.Backprop.Op: data Rec (a :: u -> Type) (b :: [u])
- Numeric.Backprop.Explicit: class RPureConstrained (c :: u -> Constraint) (ts :: [u])
+ Numeric.Backprop.Explicit: class RPureConstrained (c :: k -> Constraint) (ts :: [k])
- Numeric.Backprop.Op: [:&] :: forall u (a :: u -> Type) (b :: [u]) (r :: u) (rs :: [u]). () => !a r -> !Rec a rs -> Rec a (r : rs)
+ Numeric.Backprop.Op: [:&] :: forall {u} (a :: u -> Type) (r :: u) (rs :: [u]). !a r -> !Rec a rs -> Rec a (r : rs)
- Numeric.Backprop.Op: [RNil] :: forall u (a :: u -> Type) (b :: [u]). () => Rec a ([] :: [u])
+ Numeric.Backprop.Op: [RNil] :: forall {u} (a :: u -> Type). Rec a ('[] :: [u])

Files

CHANGELOG.md view
@@ -1,6 +1,18 @@ Changelog ========= +Version 0.2.6.5+---------------++*July 23, 2023*++<https://github.com/mstksg/backprop/releases/tag/v0.2.6.5>++*   vinyl-0.14 compatibility (@msakai), which can be disabled via cabal flag+*   GHC 9.0+ compatibility (@msakai)++Thanks to all generous contributors and commenters!+ Version 0.2.6.4 --------------- 
LICENSE view
@@ -1,4 +1,4 @@-Copyright Justin Le (c) 2018+Copyright Justin Le (c) 2020  All rights reserved. 
README.md view
@@ -183,7 +183,7 @@  [bench]: https://github.com/mstksg/backprop/blob/master/bench/bench.hs -![benchmarks](https://i.imgur.com/7L5NV4P.png)+![benchmarks](https://i.imgur.com/rLUx4x4.png)  Here we compare: 
backprop.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.35.2. -- -- see: https://github.com/sol/hpack ----- hash: 906559ac274a6fd89fe27484a5a3a192f5a009fc5317c1fd3546168b5ba7b927+-- hash: b1229ff8088fce05c68ad20c4c853349f1b30d0f9e19aa5b2c594a833b05790a  name:           backprop-version:        0.2.6.4+version:        0.2.6.5 synopsis:       Heterogeneous automatic differentation description:    Write your functions to compute your result, and the library will                 automatically generate functions to compute your gradient.@@ -24,7 +24,8 @@ copyright:      (c) Justin Le 2018 license:        BSD3 license-file:   LICENSE-tested-with:    GHC >= 8.4+tested-with:+    GHC >= 8.4 build-type:     Simple extra-source-files:     README.md@@ -51,6 +52,10 @@   type: git   location: https://github.com/mstksg/backprop +flag vinyl_0_14+  manual: False+  default: True+ library   exposed-modules:       Numeric.Backprop@@ -78,6 +83,12 @@     , vector     , vinyl >=0.9.1   default-language: Haskell2010+  if flag(vinyl_0_14)+    build-depends:+        vinyl >=0.14.2+  else+    build-depends:+        vinyl <0.14  benchmark backprop-mnist-bench   type: exitcode-stdio-1.0
doc/07-performance.md view
@@ -33,7 +33,7 @@  [bench]: https://github.com/mstksg/backprop/blob/master/bench/bench.hs -![benchmarks](https://i.imgur.com/7L5NV4P.png)+![benchmarks](https://i.imgur.com/rLUx4x4.png)  In the above, we compare: @@ -73,8 +73,8 @@ [Wengert tape]: https://dl.acm.org/citation.cfm?doid=355586.364791  In addition, usage of the "Higher-Kinded Data"-based pattern matching interface-(over the lens-based accessor interface) incurs some penalties from the-inefficient nature of GHC Generics in general.+(over the lens-based accessor interface) seems to result in more efficient+compiled code, but not by any significant amount.  Optimization Techniques -----------------------
src/Data/Type/Util.hs view
@@ -72,7 +72,7 @@     -> (forall n. VecT n f a -> r)     -> r withVec = \case-    []   -> ($ VNil)+    []   -> \f -> f VNil     x:xs -> \f -> withVec xs (f . (x :*)) {-# INLINE withVec #-} 
src/Numeric/Backprop.hs view
@@ -8,7 +8,7 @@  -- | -- Module      : Numeric.Backprop--- Copyright   : (c) Justin Le 2018+-- Copyright   : (c) Justin Le 2023 -- License     : BSD3 -- -- Maintainer  : justin@jle.im@@ -33,7 +33,7 @@ -- Then, you can use: -- -- @--- 'evalBP' :: (forall s. 'Reifies' s 'W'. 'BVar' s a -> BVar s b) -> (a -> b)+-- 'evalBP' :: (forall s. 'Reifies' s 'W' => 'BVar' s a -> BVar s b) -> (a -> b) -- @ -- -- to turn a 'BVar' function into the function on actual values @a -> b@.@@ -43,7 +43,7 @@ -- Then, there's: -- -- @--- 'gradBP' :: (forall s. 'Reifies' s 'W'. 'BVar' s a -> BVar s b) -> (a -> a)+-- 'gradBP' :: (forall s. 'Reifies' s 'W' => 'BVar' s a -> BVar s b) -> (a -> a) -- @ -- -- to automatically get the /gradient/, as well, for a given input.
src/Numeric/Backprop/Class.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE BangPatterns               #-}+{-# LANGUAGE CPP                        #-} {-# LANGUAGE DataKinds                  #-} {-# LANGUAGE DefaultSignatures          #-} {-# LANGUAGE DeriveDataTypeable         #-}@@ -19,7 +20,7 @@  -- | -- Module      : Numeric.Backprop.Class--- Copyright   : (c) Justin Le 2018+-- Copyright   : (c) Justin Le 2023 -- License     : BSD3 -- -- Maintainer  : justin@jle.im@@ -901,11 +902,13 @@     add  = coerce (add @a)     one  = coerce (one @a) +#if !MIN_VERSION_base(4,16,0) -- | @since 0.2.2.0 instance Backprop a => Backprop (SG.Option a) where     zero = coerce (zero @(Maybe a))     add  = coerce (add @(Maybe a))     one  = coerce (one @(Maybe a))+#endif  -- | @since 0.2.2.0 instance Backprop a => Backprop (SG.First a) where@@ -983,7 +986,11 @@     {-# INLINE one #-}  -- | @since 0.2.6.3+#if MIN_VERSION_vinyl(0,14,2)+instance (ReifyConstraint Backprop f rs, RMap rs, RApply rs, RecApplicative rs, NatToInt (RLength rs), RPureConstrained (IndexableField rs) rs, ToARec rs)+#else instance (ReifyConstraint Backprop f rs, RMap rs, RApply rs, RecApplicative rs, NatToInt (RLength rs), RPureConstrained (IndexableField rs) rs)+#endif       => Backprop (ARec f rs) where     zero = toARec . zero . fromARec     {-# INLINE zero #-}
src/Numeric/Backprop/Explicit.hs view
@@ -16,7 +16,7 @@  -- | -- Module      : Numeric.Backprop.Explicit--- Copyright   : (c) Justin Le 2018+-- Copyright   : (c) Justin Le 2023 -- License     : BSD3 -- -- Maintainer  : justin@jle.im
src/Numeric/Backprop/Internal.hs view
@@ -20,7 +20,7 @@  -- | -- Module      : Numeric.Backprop.Internal--- Copyright   : (c) Justin Le 2018+-- Copyright   : (c) Justin Le 2023 -- License     : BSD3 -- -- Maintainer  : justin@jle.im@@ -590,7 +590,7 @@     -> ST s (Runner s) initRunner (n, stns) (nx,xs) = do     delts <- MV.new n-    for_ (zip [n-1,n-2..] stns) $ \(i, STN (TN{..} :: TapeNode c)) ->+    for_ (zip [n-1,n-2..] stns) $ \(i, STN (TN{} :: TapeNode c)) ->       MV.write delts i $ unsafeCoerce (Nothing @c)     inps <- MV.new nx     for_ (zip [0..] xs) . uncurry $ \i z ->
src/Numeric/Backprop/Num.hs view
@@ -7,7 +7,7 @@  -- | -- Module      : Numeric.Backprop.Num--- Copyright   : (c) Justin Le 2018+-- Copyright   : (c) Justin Le 2023 -- License     : BSD3 -- -- Maintainer  : justin@jle.im
src/Numeric/Backprop/Op.hs view
@@ -11,7 +11,7 @@  -- | -- Module      : Numeric.Backprop.Op--- Copyright   : (c) Justin Le 2018+-- Copyright   : (c) Justin Le 2023 -- License     : BSD3 -- -- Maintainer  : justin@jle.im
src/Prelude/Backprop.hs view
@@ -2,7 +2,7 @@  -- | -- Module      : Prelude.Backprop--- Copyright   : (c) Justin Le 2018+-- Copyright   : (c) Justin Le 2023 -- License     : BSD3 -- -- Maintainer  : justin@jle.im
src/Prelude/Backprop/Explicit.hs view
@@ -3,7 +3,7 @@  -- | -- Module      : Prelude.Backprop.Explicit--- Copyright   : (c) Justin Le 2018+-- Copyright   : (c) Justin Le 2023 -- License     : BSD3 -- -- Maintainer  : justin@jle.im
src/Prelude/Backprop/Num.hs view
@@ -3,7 +3,7 @@  -- | -- Module      : Prelude.Backprop.Num--- Copyright   : (c) Justin Le 2018+-- Copyright   : (c) Justin Le 2023 -- License     : BSD3 -- -- Maintainer  : justin@jle.im