dival.reconstructors.regression_reconstructors module

Provides reconstructors performing regression.

class dival.reconstructors.regression_reconstructors.LinRegReconstructor(hyper_params=None, **kwargs)[source]

Bases: dival.reconstructors.reconstructor.LearnedReconstructor

HYPER_PARAMS = {'l2_regularization': {'default': 0.0, 'range': [0.0, inf], 'retrain': True}}

Reconstructor learning and applying linear regression.

Assumes the inverse operator is linear, i.e. x = A_inv * y. Learns the entries of A_inv by l2-regularized linear regression: A_inv = 1/2N * sum_i ||x_i - A_inv * y_i||^2 + alpha/2 * ||A_inv||_F^2, where (y_i, x_i) with i=1,…,N are pairs of observations and the corresponding ground truth.

weights

The weight matrix.

Type

np.ndarray

__init__(hyper_params=None, **kwargs)[source]
Parameters

hyper_params (dict, optional) – A dict with no items or an item 'l2_regularization': float. Cf. Reconstructor.init().

train(dataset)[source]

Train the reconstructor with a dataset by adapting its parameters.

Should only use the training and validation data from dataset.

Parameters

dataset (Dataset) – The dataset from which the training data should be used.

save_params(path)[source]

Save weights and hyper_params to files.

Parameters

path (str) – Folder.

property l2_regularization
load_params(path)[source]

Load weights and hyper_params from files.

Parameters

path (str) – Folder.