Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype BackGrad a v = BackGrad (forall x. (x -> VecBuilder v) -> Term a x)
- realNode :: Expr a v -> BackGrad a v
- inlineNode :: forall r u v. (VecBuilder v -> VecBuilder u) -> BackGrad r u -> BackGrad r v
- sparseNode :: forall r a z. BasicVector z => (VecBuilder z -> VecBuilder a) -> BackGrad r a -> BackGrad r z
- castBackGrad :: forall r v z. VecBuilder z ~ VecBuilder v => BackGrad r v -> BackGrad r z
Documentation
Linear expression, made for backpropagation.
It is similar to
, but has a more flexible form.Expr
BackFun
BackGrad (forall x. (x -> VecBuilder v) -> Term a x) |
Instances
(BasicVector v, VectorSpace v) => VectorSpace (BackGrad r v) Source # | |
(BasicVector v, AdditiveGroup v) => AdditiveGroup (BackGrad r v) Source # | |
type Scalar (BackGrad r v) Source # | |
Defined in Downhill.Linear.BackGrad |
realNode :: Expr a v -> BackGrad a v Source #
Creates a BackGrad
that is backed by a real node. Gradient of type v
will be computed and stored
in a graph for this node.
inlineNode :: forall r u v. (VecBuilder v -> VecBuilder u) -> BackGrad r u -> BackGrad r v Source #
inlineNode f x
will apply function f
to variable x
without creating a node. All of the gradients
coming to this expression will be forwarded to the parents of x
. However, if this expression is used
more than once, f
will be evaluated multiple times, too. It is intended to be used for newtype
wrappers.
inlineNode f x
also doesn't prevent
compiler to inline and optimize x
sparseNode :: forall r a z. BasicVector z => (VecBuilder z -> VecBuilder a) -> BackGrad r a -> BackGrad r z Source #
castBackGrad :: forall r v z. VecBuilder z ~ VecBuilder v => BackGrad r v -> BackGrad r z Source #
BackGrad
doesn't track the type of the node. Type of BackGrad
can be changed freely
as long as VecBuilder
stays the same.