| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Circuit.Pullback
Description
Linear cotangent maps — the base arrow for reverse-mode gradients.
Pullback b a is a linear map b -> a read as an arrow from b
(output cotangent) to a (input cotangent). Composition is plain
function composition — the reversal is not in this category, it is
in how a net is transposed so that output cotangents flow back to input
cotangents. Within an arrow the chain rule is then just (.).
This is the linear semantics behind reverse-mode automatic
differentiation: a Net whose wires carry pullbacks rather than smooth
maps, avoiding the second-derivative confusion that comes from trying to
compose Diff arrows directly.
Synopsis
- newtype Pullback b a = Pullback {
- runPullback :: b -> a
- evalPullback :: Net (,) Pullback b a -> b -> a
Linear cotangent arrow
A linear map from output cotangents to input cotangents, read as
an arrow b -> a.
>>>let pb = Pullback (*2) :: Pullback Double Double>>>runPullback pb 36.0
Constructors
| Pullback | |
Fields
| |
Instances
| Copy Pullback a Source # | Pullback-instance of the comonoid structure. Copy's pullback is addition; discard's pullback is the zero
cotangent. These are not used by the transposition step of reverse-mode
AD (which encodes structural rows as
NOTE: neither method here uses an |
Defined in Circuit.Pullback | |
| Merge (->) a => Merge Pullback a Source # | Pullback-instance of the additive/monoid structure. Addition's pullback is copying; zero's pullback is discarding.
|
Defined in Circuit.Pullback | |
| Category Pullback Source # | |
| Discard Pullback (a :: Type) Source # | |
Defined in Circuit.Pullback | |
| Zero (->) a => Zero Pullback (a :: Type) Source # | |
Defined in Circuit.Pullback | |
| Channel (,) Pullback Source # | Cartesian channel plumbing for pullbacks. |
| Strength (,) Pullback Source # | |
| Traced (,) Pullback Source # | The cartesian trace for pullbacks. The body is a linear map (dx, db) = f (dx, dc) solved by the same lazy knot that a differentiable arrow uses. For
strict carriers with nonzero channel self-coupling this diverges,
exactly as the lazy differentiable trace does. Unlike the differentiable
case, though, the equation here is always affine —
|
| Action (,) Pullback Source # | |
Defined in Circuit.Pullback | |
| Tensor (,) Pullback Source # | |
| Unital (,) Pullback Source # | Parallel composition pairs pullbacks independently;
|