template.runner.apply_model package

Submodules

template.runner.apply_model.apply_model module

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

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

@authors: Vinaychandran Pondenkandath , Michele Alberti

class template.runner.apply_model.apply_model.ApplyModel[source]

Bases: object

static single_run(writer, current_log_folder, model_name, lr, output_channels, classify, **kwargs)[source]

This is the main routine where train(), validate() and test() are called.

Parameters
  • writer (Tensorboard SummaryWriter) – Responsible for writing logs in Tensorboard compatible format.

  • current_log_folder (string) – Path to where logs/checkpoints are saved

  • model_name (string) – Name of the model

  • lr (float) – Value for learning rate

  • kwargs (dict) – Any additional arguments.

  • output_channels (int) – Specify shape of final layer of network.

  • classify (boolean) – Specifies whether to generate a classification report for the data or not.

Returns

None – None

Return type

None

template.runner.apply_model.evaluate module

template.runner.apply_model.evaluate.feature_extract(data_loader, model, writer, epoch, no_cuda, log_interval, classify, **kwargs)[source]

The evaluation routine

Parameters
  • data_loader (torch.utils.data.DataLoader) – The dataloader of the evaluation set

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

  • 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.

  • classify (boolean) – Specifies whether to generate a classification report for the data or not.

Returns

Return type

None

template.runner.apply_model.setup module

template.runner.apply_model.setup.set_up_dataloader(model_expected_input_size, dataset_folder, batch_size, workers, inmem, multi_crop, classify, **kwargs)[source]

Set up the dataloaders for the specified datasets.

Parameters
  • param model_expected_input_size: tuple – Specify the height and width that the model expects.

  • param dataset_folder: string – Path string that points to the three folder train/val/test. Example: ~/../../data/svhn

  • param batch_size: int – Number of datapoints to process at once

  • param workers: int – Number of workers to use for the dataloaders

  • param inmem: boolean – Flag: if False, the dataset is loaded in an online fashion i.e. only file names are stored and images are loaded on demand. This is slower than storing everything in memory.

  • param multi_crop: int – if None, the MultiCrop transform is not applied to the data. Otherwise, multi_crop contains an integer which specifies how many crops to make from each image.

  • param classify : boolean – Specifies whether to generate a classification report for the data or not.

  • param kwargs: dict – Any additional arguments.

  • return: dataloader, dataloader, dataloader, int – Three dataloaders for train, val and test. Number of classes for the model.

Module contents

class template.runner.apply_model.ApplyModel[source]

Bases: object

static single_run(writer, current_log_folder, model_name, lr, output_channels, classify, **kwargs)[source]

This is the main routine where train(), validate() and test() are called.

Parameters
  • writer (Tensorboard SummaryWriter) – Responsible for writing logs in Tensorboard compatible format.

  • current_log_folder (string) – Path to where logs/checkpoints are saved

  • model_name (string) – Name of the model

  • lr (float) – Value for learning rate

  • kwargs (dict) – Any additional arguments.

  • output_channels (int) – Specify shape of final layer of network.

  • classify (boolean) – Specifies whether to generate a classification report for the data or not.

Returns

None – None

Return type

None