This namespace contains an implementation of [[TapeCell]], a type that forms the basis for the reverse-mode automatic differentiation implementation in Emmy.
This namespace contains an implementation of [[TapeCell]], a type that forms the basis for the reverse-mode automatic differentiation implementation in Emmy.
(compare a b)
Comparator that compares [[TapeCell]] instances with each other or
non-differentials using only the [[finite-part]] of each instance. Matches the
response of equiv
.
Acts as emmy.value/compare
for non-[[TapeCell]]s.
Comparator that compares [[TapeCell]] instances with each other or non-differentials using only the [[finite-part]] of each instance. Matches the response of [[equiv]]. Acts as [[emmy.value/compare]] for non-[[TapeCell]]s.
(eq _)
(eq a b)
(eq a b & more)
For non-[[TapeCell]]s, identical to emmy.value/=
.
For [[TapeCell]] instances, equality acts on tape-tag
and tape-partials
too.
If you want to ignore the tangent components, use equiv
.
For non-[[TapeCell]]s, identical to [[emmy.value/=]]. For [[TapeCell]] instances, equality acts on [[tape-tag]] and [[tape-partials]] too. If you want to ignore the tangent components, use [[equiv]].
(equiv _)
(equiv a b)
(equiv a b & more)
Returns true if all of the supplied objects have equal tape-primal
s, false
otherwise.
Use equiv
if you want to compare non-[[TapeCell]]s with
[[TapeCell]]s and ignore all tangent components. If you do want to take the
tangent components into account, prefer eq
.
Returns true if all of the supplied objects have equal [[tape-primal]]s, false otherwise. Use [[equiv]] if you want to compare non-[[TapeCell]]s with [[TapeCell]]s and ignore all tangent components. If you _do_ want to take the tangent components into account, prefer [[eq]].
(gradient f)
(gradient f selectors)
Given some differentiable function f
, returns a function whose value at some
point can multiply an increment in the arguments to produce the best linear
estimate of the increment in the function value.
For univariate functions, gradient
computes a derivative. For
vector-valued functions, gradient
computes
the Jacobian
of f
.
For numerical differentiation, see emmy.numerical.derivative/D-numeric
.
NOTE: f
must be built out of generic operations that know how to
handle [[emmy.tape/TapeCell]] inputs in addition to any types that a
normal (f x)
call would present. This restriction does not apply to
operations like putting x
into a container or destructuring; just primitive
function calls.
Given some differentiable function `f`, returns a function whose value at some point can multiply an increment in the arguments to produce the best linear estimate of the increment in the function value. For univariate functions, [[gradient]] computes a derivative. For vector-valued functions, [[gradient]] computes the [Jacobian](https://en.wikipedia.org/wiki/Jacobian_matrix_and_determinant) of `f`. For numerical differentiation, see [[emmy.numerical.derivative/D-numeric]]. NOTE: `f` must be built out of generic operations that know how to handle [[emmy.tape/TapeCell]] inputs in addition to any types that a normal `(f x)` call would present. This restriction does _not_ apply to operations like putting `x` into a container or destructuring; just primitive function calls.
(make tag primal)
(make tag primal partials)
Returns a [[TapeCell]] instance with the supplied tag
and primal
values.
Optionally accepts partials
, a vector of pairs of the form
[<input cell> <partial>]
where <partial>
is the partial derivative of the output with respect to each
input (defaults to []
).
Returns a [[TapeCell]] instance with the supplied `tag` and `primal` values. Optionally accepts `partials`, a vector of pairs of the form ``` [<input cell> <partial>] ``` where `<partial>` is the partial derivative of the output with respect to each input (defaults to `[]`).
(tape-id tape)
Returns the -id
field of the supplied [[TapeCell]] object. Errors if any
other type is supplied.
IDs are used in the reverse pass of automatic differentiation to prevent duplicating work for [[TapeCell]]s used as input to multiple other [[TapeCell]]s.
Returns the `-id` field of the supplied [[TapeCell]] object. Errors if any other type is supplied. IDs are used in the reverse pass of automatic differentiation to prevent duplicating work for [[TapeCell]]s used as input to multiple other [[TapeCell]]s.
(tape-partials tape)
Returns the in->partial
vector of the supplied [[TapeCell]] object. Errors
if any other type is supplied.
This vector holds pairs with these two entries:
tape
tape
's tape-primal
with respect to that
inputReturns the `in->partial` vector of the supplied [[TapeCell]] object. Errors if any other type is supplied. This vector holds pairs with these two entries: - some input to `tape` - the partial derivative of `tape`'s [[tape-primal]] with respect to that input
(tape-primal x)
(tape-primal x tag)
Given a [[TapeCell]], returns the primal
field of the supplied [[TapeCell]]
object. For all other types, acts as identity.
If the optional tag
argument is supplied, only returns -primal
if (tape-tag x)
matches tag
, else acts as identity.
Given a [[TapeCell]], returns the `primal` field of the supplied [[TapeCell]] object. For all other types, acts as identity. If the optional `tag` argument is supplied, only returns `-primal` if `(tape-tag x)` matches `tag`, else acts as identity.
(tape-tag tape)
Returns the -tag
field of the supplied [[TapeCell]] object. Errors if any
other type is supplied.
Tags are used to distinguish multiple, overlapping runs of reverse-mode AD, so that [[TapeCell]] instances created for each run don't clash.
Returns the `-tag` field of the supplied [[TapeCell]] object. Errors if any other type is supplied. Tags are used to distinguish multiple, overlapping runs of reverse-mode AD, so that [[TapeCell]] instances created for each run don't clash.
(tape? x)
Returns true if the supplied object is an instance of [[TapeCell]], false otherwise.
Returns true if the supplied object is an instance of [[TapeCell]], false otherwise.
(tapify x tag)
Given a scalar input x
, wraps the input in a fresh [[TapeCell]] instance
tagged with tag
.
Given a structural x
instance, returns an identically-shaped structure with
all leaves recursively replaced by [[TapeCell]] instances.
Given a scalar input `x`, wraps the input in a fresh [[TapeCell]] instance tagged with `tag`. Given a structural `x` instance, returns an identically-shaped structure with all leaves recursively replaced by [[TapeCell]] instances.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close