pihnn.utils.derivative#
- pihnn.utils.derivative(f, z, holom=False, conjugate=False)#
Compute the derivative \(\frac{df}{dz}\) through PyTorch automatic differentiation. The method requires that ‘f’ is obtained from ‘z’ and that ‘z.requires_grad’ was set to True. If ‘z’ is complex-valued, the Wirtinger derivative is computed instead: \(\frac{\partial f}{\partial z}:= \frac{1}{2}\left(\frac{\partial f}{\partial x} - i\frac{\partial f}{\partial x}\right)\).
- Parameters:
f – Function to derivatate.
z – Variable against which to derive.
holom (bool) – If True, the complex derivative is computed by assuming ‘f’ to be holomorphic (leading to faster calculation). Meaningful only if ‘z’ is complex.
conjugate – If True, the second Wirtinger derivative \(\frac{\partial f}{\partial \overline{z}}\) is computed instead. Meaningful only if ‘z’ is complex.
- Returns:
derivative (
torch.tensor
) - Derivative of ‘f’ with respect to ‘z’.