úÎ-öEÿ™      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜ None&',-FNQSTV]d“™š›œžŸ ¡¢£¤¥¦§¨©ª«›ž›œ(c) Justin Le 2018BSD3 justin@jle.im experimental non-portableNone&'-134567;<=KSTV]ch…D>(Helper class for automatically deriving  using GHC Generics.(Helper class for automatically deriving  using GHC Generics.(Helper class for automatically deriving  using GHC Generics. A newtype wrapper over an f a for ¬ f that gives a free  instance (as well as ­ etc. instances).^Useful for performing backpropagation over functions that require some monadic context (like ® ) to perform. Newtype wrapper around a v a for ¯ v a, that gives a more efficient  instance for long vectors when a is an instance of ­. The normal  instance for vectors will map  or š over all items; this instance will completely ignore the contents of the original vector and instead produce a new vector of the same length, with all 0 or 1 using the ­ instance of a (essentially using  and   instead of  and ).. is essentially the same as normal, but using ° instead of the type's .&A newtype wrapper over an instance of ­ that gives a free  instance.Useful for things like  DerivingVia#, or for avoiding orphan instances.6Class of values that can be backpropagated in general.For instances of ­ , these methods can be given by , , and ,. There are also generic options given in Numeric.Backprop.Class for functors, ± instances, and ² instances.  instance  ³ where  =   =   =  ®If you leave the body of an instance declaration blank, GHC Generics will be used to derive instances if the type has a single constructor and each field is an instance of .KTo ensure that backpropagation works in a sound way, should obey the laws: identity  x ( y) = x  ( x) y = y1Also implies preservation of information, making ´ (°)2 an illegal implementation for lists and vectors.CThis is only expected to be true up to potential "extra zeroes" in x and y in the result.  commutativity  x y =  y x  associativity  x ( y z) =  ( x y) z  idempotence  µ  =   µ  =  unital  = gradBP ¶sNote that not all values in the backpropagation process needs all of these methods: Only the "final result" needs è, for example. These are all grouped under one typeclass for convenience in defining instances, and also to talk about sensible laws. For fine-grained control, use the "explicit" versions of library functions (for example, in Numeric.Backprop.Explicit ) instead of  based ones.(This typeclass replaces the reliance on ­ of the previous API (v0.1). ­ is strictly more powerful than h, and is a stronger constraint on types than is necessary for proper backpropagating. In particular, ·k is a problem for many types, preventing useful backpropagation for lists, variable-length vectors (like  Data.VectorA) and variable-size matrices from linear algebra libraries like hmatrix and  accelerate.O"Zero out" all components of a value. For scalar values, this should just be ¸ 0\. For vectors and matrices, this should set all components to zero, the additive identity.Should be idempotent:  µ  =  Should be as lazyU as possible. This behavior is observed for all instances provided by this library.See - for a pre-built definition for instances of ­ and !# for a definition for instances of ¹). If left blank, will automatically be +, a pre-built definition for instances of   / whose fields are all themselves instances of .pAdd together two values of a type. To combine contributions of gradients, so should be information-preserving:  x ( y) = x  ( x) y = y Should be as strictU as possible. This behavior is observed for all instances provided by this library.See - for a pre-built definition for instances of ­ and "# for a definition for instances of ±). If left blank, will automatically be +, a pre-built definition for instances of   D with one constructor whose fields are all themselves instances of .OneE all components of a value. For scalar values, this should just be ¸ 1a. For vectors and matrices, this should set all components to one, the multiplicative identity.2As the library uses it, the most important law is:  = gradBP ¶ That is,  xE is the gradient of the identity function with respect to its input.Ideally should be idempotent:  µ  =  Should be as lazyU as possible. This behavior is observed for all instances provided by this library.See - for a pre-built definition for instances of ­ and $# for a definition for instances of ¹). If left blank, will automatically be +, a pre-built definition for instances of   / whose fields are all themselves instances of .; using GHC Generics; works if all fields are instances of .; using GHC Generics; works if all fields are instances of /, but only for values with single constructors.: using GHC Generics; works if all fields are instaces of . for instances of ­.Is lazy in its argument. for instances of ­. for instances of ­.Is lazy in its argument. for instances of ¯. for instances of ¯A. Automatically pads the end of the shorter vector with zeroes. for instances of ¯. for instances of ¯, when the contained type is an instance of ­'. Is potentially more performant than  when the vectors are larger.See   for a  instance for ¯ instances that uses this for .  for instances of ¯, when the contained type is an instance of ­'. Is potentially more performant than  when the vectors are larger.See   for a  instance for ¯ instances that uses this for .! for ¹ instances." for instances of ±B. Automatically pads the end of the "shorter" value with zeroes.#i for types that are isomorphic to a list. Automatically pads the end of the "shorter" value with zeroes.$ for instances of ¹.>?@ adds together results;  and  act on results.ABCDEFGHIJKLMNOPQ and ! replace all current values, and G merges keys from both maps, adding in the case of double-occurrences.R and ! replace all current values, and G merges keys from both maps, adding in the case of double-occurrences.TW is strictX is strictY is strictZ is strict[ is strict, but  and  are lazy in their arguments.\º is treated the same as » 0 . However, , , and  preserve º if all inputs are also º.]g assumes the shorter sequence has trailing zeroes, and the result has the length of the longest input.^c assumes the shorter list has trailing zeroes, and the result has the length of the longest input._c assumes the shorter list has trailing zeroes, and the result has the length of the longest input.hijklm#)convert to list (should form isomorphism)+convert from list (should form isomorphism)  !"#$" !"#$  ¼½¾   (c) Justin Le 2018BSD3 justin@jle.im experimental non-portableNone &'-<QV]dh 3¿.Helper wrapper used for the implementation of Ÿ.œAn œ as a* describes a differentiable function from as to a.For example, a value of type œ '[Int, Bool] Double is a function from an À and a Á, returning a ³'. It can be differentiated to give a gradient of an À and a Á& if given a total derivative for the Double. If we call Á 2), then, mathematically, it is akin to a:2 f : \mathbb{Z} \times 2 \rightarrow \mathbb{R} See £, ¥, and ¤% for examples on how to run it, and œ! for instructions on creating it.NIt is simpler to not use this type constructor directly, and instead use the ³, ², ³, and ´ helper smart constructors.See Numeric.Backprop.Op#prod for a mini-tutorial on using  and 'Rec Identity'.To use an œ with the backprop library, see liftOp, liftOp1, liftOp2, and liftOp3. Construct an œ‚ by giving a function creating the result, and also a continuation on how to create the gradient, given the total derivative of a.!See the module documentation for Numeric.Backprop.Op= for more details on the function that this constructor and œ expect.žRun the function that the œ\ encodes, returning a continuation to compute the gradient, given the total derivative of a. See documentation for Numeric.Backprop.Op for more information.ŸCompose œs together, like  for functions, or liftAN.That is, given an œ as b1, an œ as b2 , and an œ as b3, it can compose them with an œ '[b1,b2,b3] c to create an œ as c. Convenient wrapper over ŸJ for the case where the second function only takes one input, so the two œ,s can be directly piped together, like for µ.¡'Convenient infix synonym for (flipped)  . Meant to be used just like µ: f :: œ '[b] c g :: œ '[a,a] b f ¡ g :: Op '[a, a] c ¢Run the function that an œ encodes, to get the result. runOp (op2 (*)) (3 :& 5 :& RNil)15£Run the function that an œX encodes, to get the resulting output and also its gradient with respect to the inputs."gradOp' (op2 (*)) (3 :& 5 :& RNil)(15, 5 :& 3 :& RNil)¤"Get the gradient function that an œN encodes, with a third argument expecting the total derivative of the result.!See the module documentaiton for Numeric.Backprop.Op for more information.¥Run the function that an œI encodes, and get the gradient of the output with respect to the inputs.!gradOp (op2 (*)) (3 :& 5 :& RNil)5 :& 3 :& RNil -- the gradient of x*y is (y, x) ¥ o xs = ¤ o xs 1 ¦An œX that coerces an item into another item whose type has the same runtime representation.4gradOp' opCoerce (Identity 5) :: (Int, Identity Int)(5, Identity 1) ¦ = « coerced à § Create an œ* with no gradient. Can be evaluated with ¢C, but will throw a runtime exception when asked for the gradient.Can be used with BVar with liftOp1, and evalBP will work fine. gradBP and backprop§ will also work fine if the result is never used in the final answer, but will throw a runtime exception if the final answer depends on the result of this operation.+Useful if your only API is exposed through backprop€. Just be sure to tell your users that this will explode when finding the gradient if the result is used in the final result.¨ Create an œ* with no gradient. Can be evaluated with ¢C, but will throw a runtime exception when asked for the gradient.Can be used with BVar with liftOp, and evalBP will work fine. gradBP and backprop§ will also work fine if the result is never used in the final answer, but will throw a runtime exception if the final answer depends on the result of this operation.+Useful if your only API is exposed through backprop€. Just be sure to tell your users that this will explode when finding the gradient if the result is used in the final result.©An œA that just returns whatever it receives. The identity function. © = « ¶ ¶ ªAn œ that takes as% and returns exactly the input tuple.#gradOp' opTup (1 :& 2 :& 3 :& RNil)*(1 :& 2 :& 3 :& RNil, 1 :& 1 :& 1 :& RNil)«An œ2 that runs the input value through an isomorphism.xWarning: This is unsafe! It assumes that the isomorphisms themselves have derivative 1, so will break for things like Ä & Å<. Basically, don't use this for any "numeric" isomorphisms.¬An œd that runs the two input values through an isomorphism. Useful for things like constructors. See « for caveats.­An œe that runs the three input values through an isomorphism. Useful for things like constructors. See « for caveats.®An œ_ that runs the input value through an isomorphism between a tuple of values and a value. See « for caveats.In Numeric.Backprop.Op0 since version 0.1.2.0, but only exported from Numeric.Backprop since version 0.1.3.0.¯An œ3 that extracts a value from an input value using a Æ.¹Warning: This is unsafe! It assumes that it extracts a specific value unchanged, with derivative 1, so will break for things that numerically manipulate things before returning them.°An œD that ignores all of its inputs and returns a given constant value.*gradOp' (opConst 10) (1 :& 2 :& 3 :& RNil)(10, 0 :& 0 :& 0 :& RNil)± Create an œ: that takes no inputs and always returns the given value.'There is no gradient, of course (using ¥Q will give you an empty tuple), because there is no input to have a gradient of.runOp (op0 10) RNil (10, RNil)For a constant œ& that takes input and ignores it, see ° and opConst'.² Create an œñ of a function taking one input, by giving its explicit derivative. The function should return a tuple containing the result of the function, and also a function taking the derivative of the result and return the derivative of the input. If we haveT \eqalign{ f &: \mathbb{R} \rightarrow \mathbb{R}\cr y &= f(x)\cr z &= g(y) } Then the derivative  \frac{dz}{dx} , it would be:/ \frac{dz}{dx} = \frac{dz}{dy} \frac{dy}{dx} If our œ represents fO, then the second item in the resulting tuple should be a function that takes  \frac{dz}{dy} and returns  \frac{dz}{dx}.As an example, here is an œ that squares its input: square :: Num a => œ '[a] a square = ²6 $ \x -> (x*x, \d -> 2 * d * x ) ARemember that, generally, end users shouldn't directly construct œDs; they should be provided by libraries or generated automatically.³ Create an œð of a function taking two inputs, by giving its explicit gradient. The function should return a tuple containing the result of the function, and also a function taking the derivative of the result and return the derivative of the input. If we haveY \eqalign{ f &: \mathbb{R}^2 \rightarrow \mathbb{R}\cr z &= f(x, y)\cr k &= g(z) } Then the gradient M \left< \frac{\partial k}{\partial x}, \frac{\partial k}{\partial y} \right>  would be:« \left< \frac{\partial k}{\partial x}, \frac{\partial k}{\partial y} \right> = \left< \frac{dk}{dz} \frac{\partial z}{dx}, \frac{dk}{dz} \frac{\partial z}{dy} \right> If our œ represents fO, then the second item in the resulting tuple should be a function that takes  \frac{dk}{dz} and returns = \left< \frac{\partial k}{dx}, \frac{\partial k}{dx} \right> .As an example, here is an œ that multiplies its inputs: mul :: Num a => œ '[a, a] a mul = op2'9 $ \x y -> (x*y, \d -> (d*y, x*d) ) ARemember that, generally, end users shouldn't directly construct œDs; they should be provided by libraries or generated automatically.´ Create an œ] of a function taking three inputs, by giving its explicit gradient. See documentation for ³ for more details.µœ for addition¶œ for subtraction·œ for multiplication¸œ for division¹œ for exponentiationºœ for negation»œ for Ǽœ for absolute value½œ for multiplicative inverse¾œ for Ä¿œ for the natural logarithmÀœ for square rootÁœ for Èœ for sineÜ for cosineÄœ for tangentÅœ for arcsineÆœ for arccosineÇœ for arctangentÈœ for hyperbolic sineÉœ for hyperbolic cosineÊœ for hyperbolic tangentËœ for hyperbolic arcsineÌœ for hyperbolic arccosineÍœ for hyperbolic arctangentŸ of œ s taking as and returning different b in bsOpM taking eac of the bs from the input . Composed œ¤œ to runInputs to run it with#The total derivative of the result. The gradient5œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍ5œž£¢¥¤±°©¯²³´¦ª«¬­®§¨Ÿ ¡µ¶·º¼»¸½¾¿À¹ÁÂÃÄÅÆÇÈÉÊËÌÍ¿ÉÊœž¡9  (c) Justin Le 2018BSD3 justin@jle.im experimental non-portableNone"#%&',-016<FNQSTV]chTè ÑqAn ephemeral Wengert Tape in the environment. Used internally to track of the computational graph of variables.'For the end user, one can just imagine  s Ñ as a required constraint on s% that allows backpropagation to work.ÒA Ò s a is a value of type a that can be "backpropagated".Functions referring to Òis are tracked by the library and can be automatically differentiated to get their gradients and results.+For simple numeric values, you can use its ­, Ë, and ÌJ instances to manipulate them as if they were the numbers they represent.If aJ contains items, the items can be accessed and extracted using lenses. A Æ b a can be used to access an a inside a b , using ^^. ( ): (Í) :: a -> Æ a b -> b (^^.) :: Ò s a -> Æ a b -> Ò s b There is also ^^? ( ), to use a Prism' or Î] to extract a target that may or may not be present (which can implement pattern matching), ^^.. ( ) to use a Î to extract all targets inside a Ò, and .~~ (å%) to set and update values inside a Ò.GIf you have control over your data type definitions, you can also use  and @ to manipulate data types by easily extracting fields out of a Ò of data types and creating Òs of data types out of Òs of their fields. See Numeric.Backprop#hkd$ for a tutorial on this use pattern.@For more complex operations, libraries can provide functions on Ò s using ˆ and related functions. This is how you can create primitive functions that users can use to manipulate your library's values. See  6https://backprop.jle.im/08-equipping-your-library.html for a detailed guide.For example, the hmatrix7 library has a matrix-vector multiplication function, #> :: L m n -> R n -> L m.+A library could instead provide a function #> :: Ò% (L m n) -> BVar (R n) -> BVar (R m)3, which the user can then use to manipulate their Òs of L m ns and R ns, etc.See Numeric.Backprop#liftops and documentation for  for more information.ÓOneE all components of a value. For scalar values, this should just be ¸ 1a. For vectors and matrices, this should set all components to one, the multiplicative identity.XShould be idempotent: Applying the function twice is the same as applying it just once.'Each type should ideally only have one Ó8. This coherence constraint is given by the typeclass .ÖxAdd together two values of a type. To combine contributions of gradients, so should ideally be information-preserving. See laws for … for the laws this should be expected to preserve. Namely, it should be commutative and associative, with an identity for a valid Ù.'Each type should ideally only have one Ö8. This coherence constraint is given by the typeclass .ÙO"Zero out" all components of a value. For scalar values, this should just be ¸ 0\. For vectors and matrices, this should set all components to zero, the additive identity.XShould be idempotent: Applying the function twice is the same as applying it just once.'Each type should ideally only have one Ù8. This coherence constraint is given by the typeclass .ÜIf a type has a ­! instance, this is the canonical Ù.ÝIf a type has a ­! instance, this is the canonical Ö.ÞIf a type has a ­! instance, this is the canonical Ó.Ï$Project out a constant value if the Ò refers to one.ÐDebugging string for an Ñ.ÒDebugging string for a  SomeTapeMode.ßLift a value into a Ò representing a constant value.ZThis value will not be considered an input, and its gradients will not be backpropagated.à, but with explicit  and .á, but with explicit  and .â, but with explicit  and .ã, but with explicit  and .ä , but with explicit  and .å, but with explicit  and .æ, but with explicit  and .ç, but with explicit  and .è, but with explicit  and .é, but with explicit  and .ê Coerce a Ò4 contents. Useful for things like newtype wrappers.ë, but with explicit  and .+Note that argument order changed in v0.2.4.ìevalBPL generalized to multiple inputs of different types. See documentation for  for more details.íThe canonical Ù for instances of .îThe canonical Ö for instances of .ïThe canonical Ó for instances of .ÓCompares the values inside the Ò.ÔCompares the values inside the Ò.Õ*This will force the value inside, as well.Ö×valØoneÙvaladdembed!ÑÒÓÔÕÖרÙÚÛÜÝÞÐÒßàáâãäåæçèéêëìíîï ÚÛÜÝÑÞßàáâãäåæÑçèéêëìíîÒïðñÓÔÕÖרÙÚÛ(c) Justin Le 2018BSD3 justin@jle.im experimental non-portableNone&'-;<=>?AQSTV]cdh| ð7Helper class for generically "splitting" and "joining" Òs into constructors. See  and .See Numeric.Backprop#hkd# for a tutorial on how to use this.eInstances should be available for types made with one constructor whose fields are all instances of  , with a ² instance.ò*Helper method for generically "splitting" Ò s out of constructors inside a Ò. See  .ó(Helper method for generically "joining" Òs inside a constructor into a Ò. See  .ñÙ6s for every item in a type level list based on their ­ instancesòí for instances of ¹óÙ6s for every item in a type level list based on their ­ instancesôÙ6s for every item in a type level list based on their ­ instancesõÓ for instances of ¹ö Generate an ÙH for every type in a type-level list, if every type has an instance of .÷ Generate an ÖH for every type in a type-level list, if every type has an instance of .ø Generate an ÓH for every type in a type-level list, if every type has an instance of .ùShorter alias for ß, inspired by the ad library.ú, but with explicit  and .û, but with explicit  and .ü, but with explicit .+Note that argument order changed in v0.2.4.ýþG but with no arguments. Useful when everything is just given through ß.þTurn a function Ò s a -> Ò s b into the function a -> b that it represents.UBenchmarks show that this should have virtually no overhead over directly writing a a -> b. ÒC is, in this situation, a zero-cost abstraction, performance-wise.See documentation of  for more information.ÿ, but with explicit  and ., Nbut with explicit  and ., but with explicit  and ., but with explicit .+Note that argument order changed in v0.2.4.þ$ for a two-argument function. See  for notes.  with explicit  and .! with explicit ." with explicit  and .# with explicit  and .$ with explicit  and . % with explicit  and . & with explicit  and .  with explicit  and .  with explicit  and . EThis instance is possible but it is not clear when it would be useful Ò of valueÒ s of fields Ò s of fieldsÒ of combined value\ œž¦§¨©ª«®¯°±²³´ÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ    _ÒÑ ÙÚÛÜñíöòÖרÝóî÷ÓÔÕÞôïøõûþÿüýúìëßùêäåæçèé  àáâã  𜞱°©²³´¦ª«®¯§¨ðòó(c) Justin Le 2018BSD3 justin@jle.im experimental non-portableNone&'-<QVdº¤ , but with ­ constraints instead of Backprop constraints.The  ­ asA in the constraint says that every value in the type-level list as must have a ­* instance. This means you can use, say, '[Double, Float, Int] , but not '[Double, Bool, String].If you stick to  concereteh, monomorphic usage of this (with specific types, typed into source code, known at compile-time), then  ­ as# should be fulfilled automatically. , but with ­ constraints instead of Backprop constraints.See  for information on the  constraint.+Note that argument order changed in v0.2.4. , but with ­ constraints instead of Backprop constraints.See module documentation for Numeric.Backprop.Num, for information on using this with tuples. , but with ­ constraints instead of Backprop constraints.See module documentation for Numeric.Backprop.Num, for information on using this with tuples.+Note that argument order changed in v0.2.4. , but with ­ constraints instead of Backprop constraints.' , but with ­ constraints instead of Backprop constraints. , but with ­ constraints instead of Backprop constraints. , but with ­ constraints instead of Backprop constraints.+Note that argument order changed in v0.2.4.  , but with ­ constraints instead of Backprop constraints.! , but with ­ constraints instead of Backprop constraints.( , but with ­ constraints instead of Backprop constraints.  , but with ­ constraints instead of Backprop constraints.) , but with ­ constraints instead of Backprop constraints.  , but with ­ constraints instead of Backprop constraints.!* , but with ­ constraints instead of Backprop constraints."" , but with ­ constraints instead of Backprop constraints.#+ , but with ­ constraints instead of Backprop constraints.5Note that many automatically-generated prisms by the lens\ package use tuples, which cannot work this this by default (because tuples do not have a ­ instance).}If you are writing an application or don't have to worry about orphan instances, you can pull in the orphan instances from  0https://hackage.haskell.org/package/NumInstances NumInstancesp. Alternatively, you can chain those prisms with conversions to the anonymous canonical strict tuple types in Numeric.Backprop.Tuple, which do have ­ instances. myPrism :: Prism' c (a, b) myPrism . iso tupT2 t2Tup :: Prism' c (T2 a b) $, , but with ­ constraints instead of Backprop constraints.Like ,, is *UNSAFE*.% , but with ­ constraints instead of Backprop constraints.See documentation for #* for more information and important notes.&- , but with ­ constraints instead of Backprop constraints.' , but with ­ constraints instead of Backprop constraints.( , but with ­ constraints instead of Backprop constraints.Since v0.2.4, requires a ­ constraint on t a.) , but with ­ constraints instead of Backprop constraints.Prior to v0.2.3, required a ­ constraint on t a.* , but with ­ constraints instead of Backprop constraints.+ , but with ­ constraints instead of Backprop constraints., , but with ­ constraints instead of Backprop constraints.- , but with ­ constraints instead of Backprop constraints..# , but with ­ constraints instead of Backprop constraints./# , but with ­ constraints instead of Backprop constraints.0% , but with ­ constraints instead of Backprop constraints.1& , but with ­ constraints instead of Backprop constraints.KTakes function giving gradient of final result given the output of function<œž¦§¨©ª«®¯°±²³´ÑÒßêìùýþ !"#$%&'()*+,-./01<ÒÑþýìßùê!#&$ "()%'./01*+,-œž±°©²³´¦ª«®¯§¨88!4#8$8(c) Justin Le 2018BSD3 justin@jle.im experimental non-portableNone %&'-<QVd£-$2)Pattern synonym wrapping manual usage of T and U. It is a pattern for a Ò s (z f) containing a z (Ò s)33Useful pattern for constructing and deconstructing Òs three-tuples.43Useful pattern for constructing and deconstructing Òs of two-tuples.57> generalized to multiple inputs of different types. See the Numeric.Backprop.Op#prod, for a mini-tutorial on heterogeneous lists.ßNot strictly necessary, because you can always uncurry a function by passing in all of the inputs in a data type containing all of the arguments or a giant tuple. However, this could potentially also be more performant.A  (Ò s) '[Double, Float, Double], for instance, is a tuple of Ò s ³, Ò s ô, and Ò s ³', and can be pattern matched on using :< (cons) and 'Ø' (nil).The   asA in the constraint says that every value in the type-level list as must have a * instance. This means you can use, say, '[Double, Float, Int] , but not '[Double, Bool, String].If you stick to  conceretei, monomorphic usage of this (with specific types, typed into source code, known at compile-time), then   as# should be fulfilled automatically.65r, but allows you to provide the gradient of the "final result" with respect to the output of your function. See 8 for more details.+Note that argument order changed in v0.2.4.7Turn a function Ò s a -> Ò s b into the function a -> b2 that it represents, also computing its gradient a as well.The Rank-N type  forall s.  s Ñ => ... is used to ensure that Ò@s do not leak out of the context (similar to how it is used in Control.Monad.ST_), and also as a reference to an ephemeral Wengert tape used to track the graph of references.8 A version of 7o that allows you to specify the gradent of your "final result" in with respect to the output of your function.OTypically, this is just the scalar 1, or a value of components that are all 1.Instead of taking the b! gradient, the you may provide a b -> b , which 8Š calls with the result of your function as the argument. This allows you to return something with the correct "shape", if not a scalar.7 is essentially 8 with ¸ 1 for scalars and ­ instances.*Note that argument order changed in v0.2.49Take a function Ò s a -> Ò s b, interpreted as a function a -> b5, and compute its gradient with respect to its input.The resulting a -> aÿ„ tells how the input (and its components) affects the output. Positive numbers indicate that the result will vary in the same direction as any adjustment in the input. Negative numbers indicate that the result will vary in the opposite direction as any adjustment in the input. Larger numbers indicate a greater sensitivity of change, and small numbers indicate lower sensitivity.See documentation of 7 for more information.FIf you want to provide an explicit "final gradient" for the end, see 8.:9L generalized to multiple inputs of different types. See documentation for 5 for more details.;7 for a two-argument function.ÂNot strictly necessary, because you can always uncurry a function by passing in all of the argument inside a data type, or just use a tuple. However, this could potentially be more performant.)For 3 and more arguments, consider using 5.<;r, but allows you to provide the gradient of the "final result" with respect to the output of your function. See 8 for more details.*Note that argument order changed in v0.2.4=9# for a two-argument function. See ; for notes.> Create an œô from a backpropagatable function. Can be useful for "storing" an otherwise Rank-N backpropagatable function in order to avoid impredicative types. But this is pretty uncommon, so this is mostly just used for low-level internal situations. L . > = ¶ > . L = ¶ ?An infix version of @, meant to evoke parallels to Í from lens.KWith normal values, you can extract something from that value with a lens: x Í myLens would extract a piece of x :: b, specified by  myLens :: Æ b a. The result has type a. xVar ? myLens would extract a piece out of xVar :: Ò s b (a Ò holding a b), specified by myLens :: Lens' b a. The result has type Ò s a (a Ò holding a a)-This is the main way to pull out values from Ò of container types.CIf you have control of your data type definitions, consider using T, which lets you break out Òs of values into ÒEs of their individual fields automatically without requiring lenses.NOTE : Usage of ?N on many fields from the same item is usually the main source of overhead in backprop7 code, if you are looking to optimize your code. See < +https://backprop.jle.im/07-performance.htmlY this performance guide> for more information, and details on mitigating this overhead.WARNINGO: Do not use with any lenses that operate "numerically" on the contents (like  multiplying).@Using a Æ, extract a value inside a Ò . Meant to evoke parallels to view from lens.See documentation for ?- for more information, caveats, and warnings.AAn infix version of B, meant to evoke parallels to õ from lens.AWith normal values, you can set something in a value with a lens: x ö myLens õ y would "set" a part of x :: b, specified by  myLens :: Æ a b, to a new value y :: a. xVar ö myLens A yVar would "set" a part of xVar :: Ò s b (a Ò holding a b), specified by  myLens :: Æ a b, to a new value given by  yVar :: Ò s a/. The result is a new (updated) value of type Ò s b.*This is the main way to set values inside Òs of container types.CNote that this does not incurr the performance overhead issues of @ and ?, and is fairly cheap.BUsing a Æ, set a value inside a Ò0. Meant to evoke parallels to "set" from lens.See documentation for A for more information.CAn infix version of D, meant to evoke parallels to ÷ from lens.>With normal values, you can set modify in a value with a lens: x ö myLens ÷ ø would "modify" a part of x :: b, specified by  myLens :: Æ a b, using the function negate :: a -> a. xVar ö myLens C ø would "modify" a part of xVar :: Ò s b (a Ò holding a b), specified by  myLens :: Æ a b, using the function negate :: BVar s a -> BVar s /. The result is a new (updated) value of type Ò s b.+Is essentially a convenient wrapper over a @ followed by a B.DUsing a Æ, modify a value inzide a ÒI. Meant to evoke parallels to "over" from lens. See documentation for C for more information.EAn infix version of G, meant to evoke parallels to ù from lens.YWith normal values, you can (potentially) extract something from that value with a lens: x ù myPrism 'would (potentially) extract a piece of x :: b, specified by  myPrism :: Î b a. The result has type ú a. xVar E myPrism +would (potentially) extract a piece out of xVar :: Ò s b (a Ò holding a b), specified by myPrism :: Prism' b a. The result has type ú (Ò s a) (ú a Ò holding a a).!This is intended to be used with Prism'@s (which hits at most one target), but will actually work with any ÎW. If the traversal hits more than one target, the first one found will be extracted.'This can be used to "pattern match" on Ò$s, by using prisms on constructors.NOTE<: Has the same potential of performance overhead issues as ?; see documentation of ? for more details.FAn *UNSAFE* version of E and G# assuming that the value is there.Is undefined if the û hits no targets.Is essentially E with ü, or H with ý.GUsing a Î, extract a single value inside a Òk, if it exists. If more than one traversal target exists, returns te first. Meant to evoke parallels to preview2 from lens. Really only intended to be used wth Prism'"s, or up-to-one target traversals.See documentation for E- for more information, warnings, and caveats.HAn infix version of I, meant to evoke parallels to þ from lens.5With normal values, you can extract all targets of a û from that value with a: x þ myTraversal $would extract all targets inside of x :: b, specified by myTraversal :: Î b a. The result has type [a]. xVar H myTraversal $would extract all targets inside of xVar :: Ò s b (a Ò holding a b), specified by myTraversal :: Traversal' b a. The result has type [Ò s a] (A list of Ò s holding as).NOTE0: Has all of the performance overhead issues of J; see documentation for J for more information.IUsing a Î, extract all targeted values inside a Ò. Meant to evoke parallels to ÿ from lens.See documentation for H. for more information, warnings, and caveats.JExtract all of the Ò s out of a  container of Òs.æNote that this associates gradients in order of occurrence in the original data structure; the second item in the gradient is assumed to correspond with the second item in the input, etc.; this can cause unexpected behavior in 4 instances that don't have a fixed number of items.NOTE=: A potential source of performance overhead. If there are n total elements, and you use m: of them, then there is an overhead cost on the order of \mathcal{O}(m n)3, with a constant factor dependent on the cost of .. Should be negligible for types with cheap  (like ³<), but may be costly for things like large matrices. See < +https://backprop.jle.im/07-performance.html) the performance guide> for for details.KCollect all of the Òs in a container into a Ò of that container's contents.ûNote that this associates gradients in order of occurrence in the original data structure; the second item in the total derivative and gradient is assumed to correspond with the second item in the input, etc.; this can cause unexpected behavior in 4 instances that don't have a fixed number of items.Note that this does not6 suffer from the same performance overhead issues as J. K is \mathcal{O}(n)É, with a very small constant factor that consistent for all types. This reveals a general property of reverse-mode automatic differentiation; "many to one" is cheap, but "one to many" is expensive.LLift an œP with an arbitrary number of inputs to a function on the appropriate number of Òs.AShould preferably be used only by libraries to provide primitive Ò& functions for their types for users.See Numeric.Backprop#liftops and documentation for L for more information, and Numeric.Backprop.Op#prod for a mini-tutorial on using .MLift an œ2 with a single input to be a function on a single Ò.AShould preferably be used only by libraries to provide primitive Ò& functions for their types for users.See Numeric.Backprop#liftops and documentation for L for more information.NLift an œ+ with two inputs to be a function on a two Òs.AShould preferably be used only by libraries to provide primitive Ò& functions for their types for users.See Numeric.Backprop#liftops and documentation for L for more information.OLift an œ/ with three inputs to be a function on a three Òs.AShould preferably be used only by libraries to provide primitive Ò& functions for their types for users.See Numeric.Backprop#liftops and documentation for L for more information.PConvert the value inside a ÒB using a given isomorphism. Useful for things like constructors.CIf you have control of your data type definitions, consider using UN, which lets you use your data type constructors themselves to join together Òs as their fields.xWarning: This is unsafe! It assumes that the isomorphisms themselves have derivative 1, so will break for things like Ä & Å<. Basically, don't use this for any "numeric" isomorphisms.QConvert the values inside two ÒHs using a given isomorphism. Useful for things like constructors. See P for caveats.CIf you have control of your data type definitions, consider using UN, which lets you use your data type constructors themselves to join together Òs as their fields.R Convert the values inside three ÒHs using a given isomorphism. Useful for things like constructors. See P for caveats.S%Convert the values inside a tuple of ÒHs using a given isomorphism. Useful for things like constructors. See P for caveats.CIf you have control of your data type definitions, consider using UN, which lets you use your data type constructors themselves to join together Òs as their fields.T Split out a Ò% of "higher-kinded data type", a la 9http://reasonablypolymorphic.com/blog/higher-kinded-data/Lets you take Ò of a value into a separate Ò of every field of that value.See Numeric.Backprop#hkd for a tutorial on usage.fThis will work with all data types made with a single constructor, whose fields are all instances of ,, where the type itself has an instance of . The type also must derive ².Note that access using TU and pattern matching is slightly slower than access using lenses (by about 10-20%). See also 2J, pattern synonym version where the deconstructor is exactly a view into T.NOTE: Like ? and @, Tn usage could potentially be the main source of performance overhead in your program. If your data type has n fields, and you use T to later use m= of those fields, there is an overhead cost on the order of \mathcal{O}(m n)3, with a constant factor dependent on the cost of J for your original data type. Should be negligible for types with cheap  (like ³;), but may be costly for things like large matrices. See  +https://backprop.jle.im/07-performance.htmlthe performance guide for for details.mHowever, there is some potential opportunities to re-write some core library functionality that would allow TA to avoid all of the significant performance overhead issues of ?4. Contact me if you are interested in helping out!U Assemble a Ò% of "higher-kinded data type", a la 9http://reasonablypolymorphic.com/blog/higher-kinded-data/It lets you take a Ò2 of every field of a value, and join them into a Ò of that value.See Numeric.Backprop#hkd for a tutorial on usage.fThis will work with all data types made with a single constructor, whose fields are all instances of ,, where the type itself has an instance of . See also 2>, a pattern synonym version where the constructor is exactly U. Note that U; does not suffer the major performance overhead issues of T. This is a general property of reverse-mode automatic differentiation: "many to one" is cheap, but "one to many" is expensive.2Ò s of fieldsÒ of combined valueTÒ of valueÒ s of fieldsUÒ s of fieldsÒ of combined valueL œž¦§¨©ª«®¯°±²³´ÑÒßêìðùýþ23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUOÒÑ 7þ98;=<5ì:6ýßùê?ACEHF@BDJKGI43PQRSLMNOTU2𜞱°©>²³´¦ª«®¯§¨?8A8C4E8F8(c) Justin Le 2018BSD3 justin@jle.im experimental non-portableNone<´ˆV., but taking explicit  and .W/, but taking explicit  and .X0, but taking explicit  and .Y1, but taking explicit  and .Z2, but taking explicit  and .[3, but taking explicit  and .\4, but taking explicit  and .]5, but taking explicit  and .^6, but taking explicit  and ._7, but taking explicit  and .`8, but taking explicit  and .a9, but taking explicit  and .b:, but taking explicit  and .cCoerce items inside a Ò.d;, but taking explicit  and .e<, but taking explicit  and .f=, but taking explicit  and .g>, but taking explicit  and .h1, but taking explicit  and .i?, but taking explicit  and .j@, but taking explicit  and .VWXYZ[\]^_`abcdefghijVXYZ[`hij\]^_Wabdefgc(c) Justin Le 2018BSD3 justin@jle.im experimental non-portableNone<ØokLifted %. More efficient than going through .lLifted .mLifted %. More efficient than going through .nLifted %. More efficient than going through .oLifted ". Undefined for situations where 9 would be undefined. More efficient than going through .pLifted ". Undefined for situations where 9 would be undefined. More efficient than going through .qLifed . Essentially just  composed with a normal list #, and is only here for convenience.rLifed A5. Essentially just  composed with a normal list A5#, and is only here for convenience.sLifted  I. Lifts backpropagatable functions to be backpropagatable functions on  ¹s.tEfficient version of s) when used to "replace" all values in a ¹ value. t x = s (¸ x) but much more efficient.u Alias for s.v Alias for t.w Alias for flip t.xLifted  I. Lifts backpropagatable functions to be backpropagatable functions on  ¹s.yLifted A9I. Lifts backpropagatable functions to be backpropagatable functions on  ¬s.zLifted A:I. Lifts backpropagatable functions to be backpropagatable functions on  ¬s.{Lifted conversion between two   instances.|Lifted conversion between two Ë and   instances.}Lifted version of  .wGradient should technically diverge whenever the fractional part is 0.5, but does not do this for convenience reasons.~Lifted version of , defined to let you return - instances as targets, instead of only other   s. Essentially the opposite of }.—The gradient should technically diverge whenever the fractional part of the downstream gradient is 0.5, but does not do this for convenience reasons.Lifted version of AB . Takes a Ò of a ! of items and returns a list of Òs for each item.3You can use this to implement "lifted" versions of  methods like , A5, etc.; however, k, m, n, o, and p2 have more efficient implementations than simply  . .€Lifted version of A?.Prior to v0.2.3, required a  constraint on t b.Lifted version of A@.Prior to v0.2.3, required a  constraint on t b.cklmnopqrstuvwxyz{|}~€kmnopx€qrstuvwlyz{|}~cu4v4w4(c) Justin Le 2018BSD3 justin@jle.im experimental non-portableNone<õE‚. , but with ­ constraints instead of Backprop constraints.ƒ/ , but with ­ constraints instead of Backprop constraints.„0 , but with ­ constraints instead of Backprop constraints.…1 , but with ­ constraints instead of Backprop constraints.†2 , but with ­ constraints instead of Backprop constraints.‡3 , but with ­ constraints instead of Backprop constraints.ˆ4 , but with ­ constraints instead of Backprop constraints.‰5 , but with ­ constraints instead of Backprop constraints.Š6 , but with ­ constraints instead of Backprop constraints.‹7 , but with ­ constraints instead of Backprop constraints.Œ Alias for Š. Alias for ‹.Ž Alias for flip ‹.8 , but with ­ constraints instead of Backprop constraints.See  0https://hackage.haskell.org/package/vector-sized vector-sized9 for a fixed-length vector type with a very appropriate ­ instance!9 , but with ­ constraints instead of Backprop constraints.‘: , but with ­ constraints instead of Backprop constraints.’; , but with ­ constraints instead of Backprop constraints.“< , but with ­ constraints instead of Backprop constraints.”= , but with ­ constraints instead of Backprop constraints.•> , but with ­ constraints instead of Backprop constraints.–B , but with ­ constraints instead of Backprop constraints.—? , but with ­ constraints instead of Backprop constraints.Prior to v0.2.3, required a ­ constraint on t b.˜@ , but with ­ constraints instead of Backprop constraints.Prior to v0.2.3, required a ­ constraint on t b.c‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜‚„…†‡–—˜ˆ‰Š‹ŒŽƒ‘’“”•cŒ44Ž4CDEFGHFGIFGJFGKFLMNOPQQRSSTUUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàááâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ                  ! " #          $  % & ' ()*+,-./01234'5 !"#$%&6789:;' !( )*"+,-#$%&<=>' !( )*"+,-#$%&./0123456789:?;<=>B?@./01234567@AB89:;<=>B?@./01234567@AB89:;<=>B?@ C D E F G H I J K L M N O P Q R S T UVWXVYZ[\]^_`VYaVbcVd [\eVfgVWhVWiVYjVWkVWlVWmVWnopqr[\s[\tVuv[w?VxyVxz{|}VY~Vx€V‚ƒVx„{…†{|‡ ˆ ‰ Š ‹ Œ  Ž   ‘ ’ “ ” • –  — ˜ ™ š › œ  ž Ÿ   ¡ ¢ £ ¤ ¥ ¦ < § ¨©ª[\«{…¬V­®{…¯VY°{…±VW²{|³V´µVf¶{…·{…¸Vu¹Vº»Vº.VW/Vº0Vº1Vº2Vº3Vº4VW6Vu8V‚¼V‚½V‚=V‚;V‚¾¿&backprop-0.2.5.0-2YkU6km7bk21njdKt9CECNumeric.BackpropNumeric.Backprop.OpNumeric.Backprop.ExplicitNumeric.Backprop.ClassNumeric.Backprop.NumPrelude.Backprop.ExplicitPrelude.BackpropPrelude.Backprop.NumData.Type.UtilGHCGenericNumeric.Backprop.InternalviewVar previewVar toListOfVarsplitBVjoinBVliftOpliftOp1liftOp2liftOp3setVar sequenceVar collectVar backpropWithN backpropNbackprop backpropWithgradBP backprop2 backpropWith2gradBP2bpOpoverVarisoVarisoVar2isoVar3isoVarNgradBPN^^..~~%~~^^?^^?!^^..sumpureproductlengthminimummaximumfoldrfoldl'fmap fmapConsttraverseliftA2liftA3 fromIntegral realToFracround fromIntegral' mapAccumL mapAccumRPtoList'reflection-2.1.3-5su5Zw7S2arHIiXmANayadData.ReflectionReifies$vinyl-0.8.1.1-Aq0Iy6xFd74Ef42TFkkRSPData.Vinyl.Core:&RNilRecRecApplicativeData.Vinyl.TypeLevelAllConstrainedGOneGAddGZeroABPrunABPNumVec runNumVecNumBPrunNumBPBackpropzeroaddone genericZero genericAdd genericOnezeroNumaddNumoneNumzeroVecaddVeconeVec zeroVecNum oneVecNum zeroFunctor addIsList addAsList oneFunctor $fMonadNumBP$fApplicativeNumBP $fNFDataNumBP$fNFDataNumVec $fFloatingABP$fFractionalABP$fNumABP $fNFDataABP $fGZero:.: $fGZeroM1 $fGZeroU1 $fGZeroV1 $fGZero:+: $fGZero:*: $fGAdd:.:$fGAddM1$fGAddU1$fGAddV1 $fGAdd:*: $fGOne:.:$fGOneM1$fGOneU1$fGOneV1 $fGOne:+: $fGOne:*:$fBackpropExpr$fBackpropKleisli$fBackprop(->)$fBackpropCompose$fBackpropProduct $fBackpropArg$fBackpropDual$fBackpropLast$fBackpropFirst$fBackpropLast0$fBackpropFirst0$fBackpropOption$fBackpropProduct0 $fBackpropSum $fBackpropU1 $fBackpropV1 $fBackprop:*: $fBackpropM1 $fBackpropK1$fBackpropIntMap $fBackpropMap$fBackpropVoid$fBackpropConst$fBackpropProxy$fBackpropIdentity$fBackprop(,,,,)$fBackprop(,,,)$fBackprop(,,) $fBackprop(,) $fBackprop()$fBackpropMaybe $fBackpropSeq$fBackpropNonEmpty $fBackprop[]$fBackpropVector$fBackpropVector0$fBackpropVector1$fBackpropVector2$fBackpropDouble$fBackpropFloat$fBackpropComplex$fBackpropRatio$fBackpropWord64$fBackpropWord32$fBackpropWord16$fBackpropWord$fBackpropWord8$fBackpropNatural$fBackpropInteger $fBackpropInt$fGOneK1$fGAddK1 $fGZeroK1 $fBackpropABP$fBackpropNumVec$fBackpropNumBP $fShowNumBP $fReadNumBP $fEqNumBP $fOrdNumBP $fDataNumBP$fGenericNumBP$fFunctorNumBP$fFoldableNumBP$fTraversableNumBP $fNumNumBP$fFractionalNumBP$fFloatingNumBP $fShowNumVec $fReadNumVec $fEqNumVec $fOrdNumVec $fDataNumVec$fGenericNumVec$fFunctorNumVec$fApplicativeNumVec $fMonadNumVec$fAlternativeNumVec$fMonadPlusNumVec$fFoldableNumVec$fTraversableNumVec $fShowABP $fReadABP$fEqABP$fOrdABP $fDataABP $fGenericABP $fFunctorABP$fApplicativeABP $fMonadABP$fAlternativeABP$fMonadPlusABP $fFoldableABP$fTraversableABPOp runOpWith composeOp composeOp1~.evalOprunOp gradOpWithgradOpopCoercenoGrad1noGradidOpopTupopIsoopIso2opIso3opIsoNopLensopConstop0op1op2op3+.-.*./.**.negateOpsignumOpabsOprecipOpexpOplogOpsqrtOp logBaseOpsinOpcosOptanOpasinOpacosOpatanOpsinhOpcoshOptanhOpasinhOpacoshOpatanhOp $fFloatingOp$fFractionalOp$fNumOpWBVarOneFuncOFrunOFAddFuncAFrunAFZeroFuncZFrunZFzfNumafNumofNumconstVar coerceVarevalBPNzeroFuncaddFunconeFuncBVGroupzfNums zfFunctorafNumsofNums ofFunctor zeroFuncsaddFuncsoneFuncsautoevalBP0evalBPevalBP2$fBVGroups::+::+:$fBVGroups::*::*:$fBVGroups[]U1U1$fBVGroups[]V1V1$fBVGroupsasM1M1$fBVGroups[]K1K1BVT3T2coerce<$><$$> ReplicateVecVecT:+VNil:* runzipWithvmapwithVecvecToRecfillRec rtraverse_ rzipWithM_ zipVecListsplitRecp1p2s1s2baseGHC.Base ApplicativeGHC.NumNumghc-prim GHC.TypesIO&vector-0.12.0.1-LflPw1fguMb6as60UrZpxNData.Vector.Generic.BaseVector+GHC.ExtsIsList GHC.GenericsDoubleGHC.ListzipWith.id fromIntegerconstFunctorNothingJustgonegaddgzeroOpContIntBoolData.TraversablesequenceGHC.Prim GHC.Floatexplog(microlens-0.4.9.1-3wqsjzVxKHI2nLhceIdmENLens.Micro.TypeLens'signumlogBaseOC runOpContGHC.Real FractionalFloating Lens.Micro^. Traversal'bvConstdebugIRInpRefdebugSTN $fOrdBVar$fEqBVar $fNFDataBVar$fBackpropBVar insertNode gradRunner bumpMaybeRunnerR_rDelta_rInputswRef SomeTapeNodeSTN_stnNodeTapeNodeTN _tnInputs_tnGradIR_irIx_irAdd_irEmbedBRefBRInpBRIxBRC_bvRef_bvValgsplitBVgjoinBVFloat.~ Data.Function&%~negate^?Maybe Traversal Data.MaybefromJusthead^..toListOf Traversable Data.FoldableFoldableIntegralRealRealFrac