Estimators
The base class of every algorithm, with its tags, fit history and (de)serialisation. See Estimators for a guided tour.
Estimator
Estimator(*, faithful=True, dtype=None, device=None, layout=None, **options)
Base class of optix estimators.
Subclasses define tags (which registers them), the paper and
recommended presets, spell out their options as keyword-only
parameters defaulting to None, and call
self._resolve(faithful, locals()), which also routes a layout
parameter to self.layout. They implement _fit and
_apply; the public fit /
apply run them under torch.no_grad().
Note
Subclasses receive a Labeled array in _fit /
_apply whenever a layout is set, so that the io and stats helpers
pick it up; _layout_of and _map_shape give the layout (default
included) and the shape of the parameter maps.
Attributes:
| Name | Type | Description |
|---|---|---|
options |
dict
|
Resolved hyper-parameters. |
is_faithful |
bool
|
Whether the resolved options equal the paper preset. |
estimates |
dict of str to Estimate
|
Results of |
layout |
Layout or None
|
|
history |
History
|
|
Set up the working backend and resolve the options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
faithful
|
bool
|
Selects the preset of defaults: |
True
|
dtype
|
optional
|
Working backend (default: configuration; the device follows a Tensor input when unset). |
None
|
device
|
optional
|
Working backend (default: configuration; the device follows a Tensor input when unset). |
None
|
layout
|
Layout
|
None
|
|
**options
|
object
|
Hyper-parameters (the base's view of the subclass's options). |
{}
|
fit
fit(data, *, layout=None, init=None, callback=None, verbose=False)
Fit the model to data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
array - like or Labeled
|
Data; |
required |
layout
|
Layout
|
Axis roles (default: that of a labelled |
None
|
init
|
Estimate, sequence of Estimate, or Estimator
|
Initial values (cloned; the caller's objects are not modified). |
None
|
callback
|
callable
|
Called by iterative estimators after each iteration. |
None
|
verbose
|
bool
|
|
False
|
Returns:
| Type | Description |
|---|---|
Estimator
|
self, with |
apply
apply(data, out=None)
Apply the fitted model (e.g. correct the data).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
array - like or Labeled
|
Data, in the layout of the fit (unless labelled otherwise). |
required |
out
|
writable array-like
|
Output (tensor, numpy, zarr, memmap...). Default: a new tensor
on the device of |
None
|
Returns:
| Type | Description |
|---|---|
writable array-like
|
|
to
to(device=None, dtype=None)
Move estimates and any tensor state (in place).
state_dict
state_dict()
Everything needed to rebuild the fitted estimator.
save
save(path)
Save with torch.save (no pickled classes).
Tags
dataclass
Tags(targets, streaming, modality=('any',), noise='none', many_frames=False, reference='')
Static description of an estimator.
Attributes:
| Name | Type | Description |
|---|---|---|
targets |
tuple of str
|
What it estimates, e.g. |
streaming |
str
|
Data access pattern: |
modality |
tuple of str
|
Imaging modalities it is meant for. |
noise |
str
|
Noise model: |
many_frames |
bool
|
Whether it needs many frames. |
reference |
str
|
Citation or DOI. |
History
dataclass
Objective trace of an iterative fit (objective is maximised).
Attributes:
| Name | Type | Description |
|---|---|---|
objective |
list of float
|
|
extras |
dict of str to list of float
|
Other per-iteration diagnostics. |
converged |
bool
|
|
reason |
str
|
Why the fit stopped. |
record
record(objective, **extras)
Append one iteration.
Takes Python floats: the caller does the single .item() per
iteration.
gain
gain()
Relative change of the last step, (Lₜ − Lₜ₋₁) / |Lₜ|.
Returns inf with fewer than two records.
estimators
estimators()
Registered estimator classes (those defining tags), by name.