mici.autograd_wrapper module#

Additional autograd differential operators.

mici.autograd_wrapper.grad_and_value(fun, x)[source]#

Makes a function that returns both gradient and value of a function.

Parameters:
  • fun (ScalarFunction) –

  • x (ArrayLike) –

Return type:

tuple[ArrayLike, ScalarLike]

mici.autograd_wrapper.hessian_grad_and_value(fun, x)[source]#

Makes a function that returns the Hessian, gradient & value of a function.

Assumes that the function fun broadcasts along the first dimension of the input being differentiated with respect to such that a batch of outputs can be computed concurrently for a batch of inputs.

Parameters:
  • fun (ArrayFunction) –

  • x (ArrayLike) –

Return type:

tuple[ArrayLike, ArrayLike, ScalarLike]

mici.autograd_wrapper.jacobian_and_value(fun, x)[source]#

Makes a function that returns both the Jacobian and value of a function.

Assumes that the function fun broadcasts along the first dimension of the input being differentiated with respect to such that a batch of outputs can be computed concurrently for a batch of inputs.

Parameters:
  • fun (ArrayFunction) –

  • x (ArrayLike) –

Return type:

tuple[ArrayLike, ArrayLike]

mici.autograd_wrapper.mhp_jacobian_and_value(fun, x)[source]#

Makes a function that returns MHP, Jacobian and value of a function.

For a vector-valued function fun the matrix-Hessian-product (MHP) is here defined as a function of a matrix m corresponding to

mhp(m) = sum(m[:, :, None] * h[:, :, :], axis=(0, 1))

where h is the vector-Hessian of f = fun(x) wrt x i.e. the rank-3 tensor of second-order partial derivatives of the vector-valued function, such that

h[i, j, k] = ∂²f[i] / (∂x[j] ∂x[k])

Assumes that the function fun broadcasts along the first dimension of the input being differentiated with respect to such that a batch of outputs can be computed concurrently for a batch of inputs.

Parameters:
  • fun (ArrayFunction) –

  • x (ArrayLike) –

Return type:

tuple[MatrixHessianProduct, ArrayLike, ArrayLike]

mici.autograd_wrapper.mtp_hessian_grad_and_value(fun, x)[source]#

Makes a function that returns MTP, Jacobian and value of a function.

For a scalar-valued function fun the matrix-Tressian-product (MTP) is here defined as a function of a matrix m corresponding to

mtp(m) = sum(m[:, :] * t[:, :, :], axis=(-1, -2))

where t is the ‘Tressian’ of f = fun(x) wrt x i.e. the 3D array of third-order partial derivatives of the scalar-valued function such that

t[i, j, k] = ∂³f / (∂x[i] ∂x[j] ∂x[k])

Assumes that the function fun broadcasts along the first dimension of the input being differentiated with respect to such that a batch of outputs can be computed concurrently for a batch of inputs.

Parameters:
  • fun (ArrayFunction) –

  • x (ArrayLike) –

Return type:

tuple[MatrixTressianProduct, ArrayLike, ArrayLike, ScalarLike]