sparse.nn.trainer.TestMatchingPursuit¶
- class sparse.nn.trainer.TestMatchingPursuit(model: Module, criterion: Module, data_loader: DataLoader, optimizer: Optimizer, scheduler: Optional[Union[_LRScheduler, ReduceLROnPlateau]] = None, **kwargs)[source]¶
Bases:
TrainerAutoencoder
Test Matching Pursuit with the fixed Softshrink threshold (embedded in a model) and trained weights.
- __init__(model: Module, criterion: Module, data_loader: DataLoader, optimizer: Optimizer, scheduler: Optional[Union[_LRScheduler, ReduceLROnPlateau]] = None, **kwargs)¶
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