mici.autodiff.autograd_wrapper module#

Autograd differential operators.

mici.autodiff.autograd_wrapper.grad_and_value(func)[source]#

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

Parameters:

func (ScalarFunction)

Return type:

GradientFunction

mici.autodiff.autograd_wrapper.hessian_grad_and_value(func)[source]#

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

Parameters:

func (ArrayFunction)

Return type:

HessianFunction

mici.autodiff.autograd_wrapper.jacobian_and_value(func)[source]#

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

Parameters:

func (ArrayFunction)

Return type:

JacobianFunction

mici.autodiff.autograd_wrapper.mhp_jacobian_and_value(func)[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])

Parameters:

func (ArrayFunction)

Return type:

MatrixHessianProductFunction

mici.autodiff.autograd_wrapper.mtp_hessian_grad_and_value(func)[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])

Parameters:

func (ArrayFunction)

Return type:

MatrixTressianProductFunction

mici.autodiff.autograd_wrapper.vjp_and_value(func)[source]#

Makes a function that returns vector-Jacobian-product and value of a function.

For a vector-valued function fun the vector-Jacobian-product (VJP) is here defined as a function of a vector v corresponding to

vjp(v) = v @ j

where j is the Jacobian of f = fun(x) wrt x i.e. the rank-2 tensor of first-order partial derivatives of the vector-valued function, such that

j[i, k] = ∂f[i] / ∂x[k]

Parameters:

func (ScalarFunction)

Return type:

VectorJacobianProductFunction