dipas.optimize module¶
-
class
dipas.optimize.JacobianAdapter(f_compute, *, ref_data, verbose=False, history=False)¶ Bases:
objectThis class allows combination with external optimizers which require the Jacobian.
Can be used together with
scipy.optimize.least_squaresfor example.- Parameters
f_compute (callable) – This function should compute the desired quantity, given a tensor of inputs. It will be called with a single argument, a tensor of shape
(N,)and must output a single tensor of shape(M,).ref_data (torch.Tensor, shape (M,)) – The reference data to compute the residuals w.r.t. the output of f_compute. Must have the same shape as the output of f_compute.
verbose (bool, optional) – If True then at every iteration the current mean squared error is printed to
sys.stdout.history (bool, optional) – If True then at every iteration the current estimate and residuals are saved in the history attribute.
-
step¶ The current step during the optimization. This attribute is incremented by one for each
__call__of the adapter.- Type
int
-
history¶ If the history parameter is set to true then this list is appended the current parameter estimate and residuals as a tuple on every iteration.
- Type
list
-
class
Progress(estimate, residual)¶ Bases:
tuple-
property
estimate¶ Alias for field number 0
-
property
residual¶ Alias for field number 1
-
property
-
jacobian(_)¶ Return the Jacobian corresponding to the last estimate.