Classification¶
-
class
olympus.tasks.classification.Classification(classifier, optimizer, lr_scheduler, dataloader, criterion=None, device=None, storage=None, preprocessor=None, metrics=None)[source]¶ Bases:
olympus.tasks.task.TaskTrain a model to recognize a range of classes
Attributes: - classifier: Module
Module taking sample data and returning the probability of the sample belonging to a range of classes
- optimizer: Optimizer
Optimizer taking model’s parameters
- criterion: Module
Function evaluating the quality of the model’s predictions, also named cost function or loss function
- lr_scheduler: LRSchedule
Learning Scheduler, updates the learning rates periodically
- dataloader: Iterator
Batch sample iterator used to train the model
- preprocessor: Preprocessor
Set of functions that transform the inputs before it is given to the model
- device:
Acceleration device to run the task on
- storage: Storage
Where to save checkpoints in case of failures
Methods
eval_loss(batch)This is used to compute validation and test loss fit(epochs[, context])Execute a single batch get_current_space()Get currently defined parameter space get_space()Return hyper parameter space init([optimizer, lr_schedule, model, uid])Parameters: load_state_dict(state[, strict])Try to load a previous unfinished state to resume state_dict([destination, prefix, keep_vars])Save a state the task can go back to if an error occur accuracy epoch parameters predict predict_log_probabilities predict_scores report resumed set_device step summary -
fit(epochs, context=None)[source]¶ Execute a single batch
Parameters: - epoch: int
current step in the training process
- context: dict
Optional Context
Notes
You should wrap whatever code you have here inside a
BadResumeGuardto prevent users from resuming a failed task that can have a bad statesTo resume a task, you need to create a clean one with the same hyper parameters. It will pickup automatically where at its last checkpoint
-
init(optimizer=None, lr_schedule=None, model=None, uid=None)[source]¶ Parameters: - optimizer: Dict
Optimizer hyper parameters!s
- lr_schedule: Dict
lr schedule hyper parameters
- model: Dict
model hyper parameters
- uid: Optional[str]
trial id to use for logging. When using orion usually it already created a trial for us we just need to append to it
-
load_state_dict(state, strict=True)[source]¶ Try to load a previous unfinished state to resume
Notes
You should wrap whatever code you have here inside a
BadResumeGuardto prevent users from resuming a failed task that can have a bad statesTo resume a task, you need to create a clean one with the same hyper parameters. It will pickup automatically where at its last checkpoint
-
model¶