dynax.util

Functions

broadcast_right(arr, target)

Append trailing size-1 axes to arr until it has the same ndim as target.

dim2shape(x)

Convert a dimension specifier to a shape tuple.

monkeypatch_pretty_print()

mse(target, prediction[, axis])

Compute mean-squared error.

multitone(length, num_tones[, first_tone])

Create a periodic bandpassed multitone signal.

nmse(target, prediction[, axis])

Compute normalized mean-squared error.

nrmse(target, prediction[, axis])

Compute normalized root mean-squared error.

pretty(tree)

Return a pretty-formatted string representation of an equinox pytree.

value_and_jacfwd(fun, x)

Evaluate fun and its forward-mode Jacobian at x.

value_and_jacrev(fun, x)

Evaluate fun and its reverse-mode Jacobian at x.

dynax.util.value_and_jacfwd(fun, x)[source]

Evaluate fun and its forward-mode Jacobian at x.

Parameters:
  • fun (Callable) – Function whose Jacobian is to be computed.

  • x (Array) – Point at which function and Jacobian is evaluated.

Returns:

tuple[Array, Array] – Tuple (y, jac) of the function value and Jacobian matrix at x.

From this issue.

dynax.util.value_and_jacrev(fun, x)[source]

Evaluate fun and its reverse-mode Jacobian at x.

Parameters:
  • fun (Callable) – Function whose Jacobian is to be computed.

  • x (Array) – Point at which function and Jacobian is evaluated.

Returns:

tuple[Array, Array] – Tuple (y, jac) of the function value and Jacobian matrix at x.

From this issue.

dynax.util.mse(target, prediction, axis=0)[source]

Compute mean-squared error.

Return type:

Array

dynax.util.nmse(target, prediction, axis=0)[source]

Compute normalized mean-squared error.

Return type:

Array

dynax.util.nrmse(target, prediction, axis=0)[source]

Compute normalized root mean-squared error.

Return type:

Array

dynax.util.pretty(tree)[source]

Return a pretty-formatted string representation of an equinox pytree.

dynax.util.broadcast_right(arr, target)[source]

Append trailing size-1 axes to arr until it has the same ndim as target.

dynax.util.dim2shape(x)[source]

Convert a dimension specifier to a shape tuple.

Parameters:

x (int | Literal['scalar']) – Either “scalar” or a non-negative integer number of dimensions.

Returns:

tuple() if x is “scalar”, otherwise (x,).

dynax.util.multitone(length, num_tones, first_tone=0)[source]

Create a periodic bandpassed multitone signal.

Has flat spectrum and crest factor <= 2.

Return type:

Array

From: S. Boyd, “Multitone Signals with Low Crest Factor”

IEEE Transactions on Circuits and Systems, CAS-33(10):1018-1022, October 1986