math¶
-
zfit.z.math.
autodiff_gradient
(func: Callable, params: Iterable[zfit.Parameter]) → tensorflow.python.framework.ops.Tensor[source]¶ Calculate using autodiff the gradients of func() wrt params.
Automatic differentiation (autodiff) is a way of retreiving the derivative of x wrt y. It works by consecutively applying the chain rule. All that is needed is that every operation knows its own derivative. TensorFlow implements this and anything using tf.* operations only can use this technique.
- Args:
func (Callable): Function without arguments that depends on params params (ZfitParameter): Parameters that func implicitly depends on and with respect to which the
derivatives will be taken.- Returns:
- tf.Tensor: gradient
-
zfit.z.math.
autodiff_hessian
(func: Callable, params: Iterable[zfit.Parameter]) → tensorflow.python.framework.ops.Tensor[source]¶ Calculate using autodiff the hessian matrix of func() wrt params.
Automatic differentiation (autodiff) is a way of retrieving the derivative of x wrt y. It works by consecutively applying the chain rule. All that is needed is that every operation knows its own derivative. TensorFlow implements this and anything using tf.* operations only can use this technique.
- Args:
func (Callable): Function without arguments that depends on params params (ZfitParameter): Parameters that func implicitly depends on and with respect to which the
derivatives will be taken.- Returns:
- tf.Tensor: hessian matrix
-
zfit.z.math.
autodiff_value_gradients
(func: Callable, params: Iterable[zfit.Parameter]) → [<class 'tensorflow.python.framework.ops.Tensor'>, <class 'tensorflow.python.framework.ops.Tensor'>][source]¶ Calculate using autodiff the gradients of func() wrt params; also return func().
Automatic differentiation (autodiff) is a way of retreiving the derivative of x wrt y. It works by consecutively applying the chain rule. All that is needed is that every operation knows its own derivative. TensorFlow implements this and anything using tf.* operations only can use this technique.
- Args:
func (Callable): Function without arguments that depends on params params (ZfitParameter): Parameters that func implicitly depends on and with respect to which the
derivatives will be taken.- Returns:
- tuple(tf.Tensor, tf.Tensor): value and gradient
-
zfit.z.math.
automatic_value_gradients_hessian
(func: Callable, params: Iterable[zfit.Parameter]) → [<class 'tensorflow.python.framework.ops.Tensor'>, <class 'tensorflow.python.framework.ops.Tensor'>, <class 'tensorflow.python.framework.ops.Tensor'>][source]¶ Calculate using autodiff the gradients and hessian matrix of func() wrt params; also return func().
Automatic differentiation (autodiff) is a way of retreiving the derivative of x wrt y. It works by consecutively applying the chain rule. All that is needed is that every operation knows its own derivative. TensorFlow implements this and anything using tf.* operations only can use this technique.
- Args:
func (Callable): Function without arguments that depends on params params (ZfitParameter): Parameters that func implicitly depends on and with respect to which the
derivatives will be taken.- Returns:
- tuple(tf.Tensor, tf.Tensor, tf.Tensor): value, gradient and hessian matrix
-
zfit.z.math.
interpolate
(t, c)[source]¶ Multilinear interpolation on a rectangular grid of arbitrary number of dimensions.
Parameters: - t (tf.Tensor) – Grid (of rank N)
- c (tf.Tensor) – Tensor of coordinates for which the interpolation is performed
Returns: 1D tensor of interpolated value
Return type: tf.Tensor
-
zfit.z.math.
numerical_gradient
(func: Callable, params: Iterable[zfit.Parameter]) → tensorflow.python.framework.ops.Tensor[source]¶ Calculate numerically the gradients of func() with respect to params.
Parameters: - func (Callable) – Function without arguments that depends on params
- params (ZfitParameter) – Parameters that func implicitly depends on and with respect to which the derivatives will be taken.
Returns: gradients
Return type: tf.Tensor
-
zfit.z.math.
numerical_hessian
(func: Callable, params: Iterable[zfit.Parameter]) → tensorflow.python.framework.ops.Tensor[source]¶ Calculate numerically the hessian matrix of func() with respect to params.
Parameters: - func (Callable) – Function without arguments that depends on params
- params (ZfitParameter) – Parameters that func implicitly depends on and with respect to which the derivatives will be taken.
Returns: hessian matrix
Return type: tf.Tensor
-
zfit.z.math.
numerical_value_gradients
(func: Callable, params: Iterable[zfit.Parameter]) → [<class 'tensorflow.python.framework.ops.Tensor'>, <class 'tensorflow.python.framework.ops.Tensor'>][source]¶ Calculate numerically the gradients of func() with respect to params, also returns the value of func().
Parameters: - func (Callable) – Function without arguments that depends on params
- params (ZfitParameter) – Parameters that func implicitly depends on and with respect to which the derivatives will be taken.
Returns: value, gradient
Return type: tuple(tf.Tensor, tf.Tensor)
-
zfit.z.math.
numerical_value_gradients_hessian
(func: Callable, params: Iterable[zfit.Parameter]) → [<class 'tensorflow.python.framework.ops.Tensor'>, <class 'tensorflow.python.framework.ops.Tensor'>, <class 'tensorflow.python.framework.ops.Tensor'>][source]¶ Calculate numerically the gradients and hessian matrix of func() wrt params; also return func().
Parameters: - func (Callable) – Function without arguments that depends on params
- params (ZfitParameter) – Parameters that func implicitly depends on and with respect to which the derivatives will be taken.
Returns: value, gradient and hessian matrix
Return type: tuple(tf.Tensor, tf.Tensor, tf.Tensor)