Liking cljdoc? Tell your friends :D

emmy.tape

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.
raw docstring

compareclj/s

(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.
sourceraw docstring

eqclj/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]].
sourceraw docstring

equivclj/s

(equiv _)
(equiv a b)
(equiv a b & more)

Returns true if all of the supplied objects have equal tape-primals, 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]].
sourceraw docstring

gradientclj/s

(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.
sourceraw docstring

makeclj/s

(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 `[]`).
sourceraw docstring

processclj/s

(process sensitivities tape)
source

tape-idclj/s

(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.
sourceraw docstring

tape-partialsclj/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:

  • some input to tape
  • the partial derivative of tape's tape-primal with respect to that input
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:

- some input to `tape`
- the partial derivative of `tape`'s [[tape-primal]] with respect to that
  input
sourceraw docstring

tape-primalclj/s

(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.
sourceraw docstring

tape-tagclj/s

(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.
sourceraw docstring

tape?clj/s

(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.
sourceraw docstring

tapifyclj/s

(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.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close