sparse.nn.trainer.TestMatchingPursuitParameters¶
- class sparse.nn.trainer.TestMatchingPursuitParameters(model: Module, criterion: Module, data_loader: DataLoader, bmp_params_range: Tensor, param_name='param', **kwargs)[source]¶
Bases:
TrainerAutoencoder
Swipe through a range of Softshrink threshold parameters
bmp_params_range
and show the best one.The user then can pick the “best” parameter by looking at the PSNR and sparsity plots - the choice is not trivial and depends on the application.
- __init__(model: Module, criterion: Module, data_loader: DataLoader, bmp_params_range: Tensor, param_name='param', **kwargs)[source]¶
Methods
__init__
(model, criterion, data_loader, ...)checkpoint_path
([best])Get the checkpoint path, given the mode.
full_forward_pass
([train])Fixes the model weights, evaluates the epoch score and updates the monitor.
is_unsupervised
()- Returns
log_trainer
()Logs the trainer in Visdom text field.
monitor_functions
()Override this method to register Visdom callbacks on each epoch.
open_monitor
([offline])Opens a Visdom monitor.
plot_autoencoder
()Plots AutoEncoder reconstruction.
restore
([checkpoint_path, best, strict])Restores the trainer progress and the model from the path.
save
([best])Saves the trainer and the model parameters to
self.checkpoint_path(best)
.state_dict
()- Returns
train
([n_epochs, mutual_info_layers, ...])User-entry function to train the model for
n_epochs
.train_batch
(batch)The core function of a trainer to update the model parameters, given a batch.
train_epoch
(epoch)Trains an epoch.
train_mask
([mask_explain_params])Train mask to see what part of an image is crucial from the network perspective (saliency map).
training_finished
()Training is finished callback.
training_started
()Training is started callback.
update_accuracy
([train])Updates the accuracy of the model.
update_best_score
(score)If
score
is greater than theself.best_score
, save the model.Attributes
best_score_type
epoch
The current epoch, int.
watch_modules