template.runner.process_activation package

Submodules

template.runner.process_activation.activation module

class template.runner.process_activation.activation.Activation(log_folder, model_name, dataset, process_size, save_cover, no_cuda)[source]

Bases: object

add_epoch(epoch_number, epoch_accuracy, model)[source]

This method collect, compute and save all activation data (and mean activation data) from a given epoch

Parameters
  • epoch_number (int) – Epoch number of the processing.

  • epoch_accuracy (int) – Epoch accuracy retrived by the last training.

  • model (Torch.nn.model) – PyTorch model trained.

Returns

Return type

None

init(model)[source]

This method initialize internal global according to model passed. Storage and create custom folders on the disk.

Parameters

model (Torch.nn.model) – PyTorch model initialized.

Returns

Return type

None

resolve_items()[source]

This method prepare all the items to process, prepare and save cover for items (if needed), create the model’s shape internally.

Parameters

None

Returns

Return type

None

template.runner.process_activation.evaluate module

template.runner.process_activation.evaluate.test(test_loader, model, criterion, writer, epoch, no_cuda=False, log_interval=20, **kwargs)[source]

Wrapper for _evaluate() with the intent to test the model

template.runner.process_activation.evaluate.validate(val_loader, model, criterion, writer, epoch, no_cuda=False, log_interval=20, **kwargs)[source]

Wrapper for _evaluate() with the intent to validate the model.

template.runner.process_activation.process_activation module

This file is the template for the boilerplate of train/test of a DNN for image classification

There are a lot of parameter which can be specified to modify the behaviour and they should be used instead of hard-coding stuff.

class template.runner.process_activation.process_activation.ProcessActivation[source]

Bases: object

static single_run(writer, current_log_folder, model_name, epochs, lr, decay_lr, validation_interval, checkpoint_all_epochs, **kwargs)[source]

DESC

Parameters

Param – Desc

Returns

Return type

None

template.runner.process_activation.train module

template.runner.process_activation.train.train(train_loader, model, criterion, optimizer, writer, epoch, no_cuda=False, log_interval=25, **kwargs)[source]

Training routine

Parameters
  • train_loader (torch.utils.data.DataLoader) – The dataloader of the train set.

  • model (torch.nn.module) – The network model being used.

  • criterion (torch.nn.loss) – The loss function used to compute the loss of the model.

  • optimizer (torch.optim) – The optimizer used to perform the weight update.

  • writer (tensorboardX.writer.SummaryWriter) – The tensorboard writer object. Used to log values on file for the tensorboard visualization.

  • epoch (int) – Number of the epoch (for logging purposes).

  • no_cuda (boolean) – Specifies whether the GPU should be used or not. A value of ‘True’ means the CPU will be used.

  • log_interval (int) – Interval limiting the logging of mini-batches. Default value of 10.

Returns

top1.avg – Accuracy of the model of the evaluated split

Return type

float

template.runner.process_activation.train.train_one_mini_batch(model, criterion, optimizer, input_var, target_var, loss_meter, acc_meter)[source]

This routing train the model passed as parameter for one mini-batch

Parameters
  • model (torch.nn.module) – The network model being used.

  • criterion (torch.nn.loss) – The loss function used to compute the loss of the model.

  • optimizer (torch.optim) – The optimizer used to perform the weight update.

  • input_var (torch.autograd.Variable) – The input data for the mini-batch

  • target_var (torch.autograd.Variable) – The target data (labels) for the mini-batch

  • loss_meter (AverageMeter) – Tracker for the overall loss

  • acc_meter (AverageMeter) – Tracker for the overall accuracy

Returns

  • acc (float) – Accuracy for this mini-batch

  • loss (float) – Loss for this mini-batch

Module contents

class template.runner.process_activation.ProcessActivation[source]

Bases: object

static single_run(writer, current_log_folder, model_name, epochs, lr, decay_lr, validation_interval, checkpoint_all_epochs, **kwargs)[source]

DESC

Parameters

Param – Desc

Returns

Return type

None