Other

Mean and variance online measures

MeanOnline([tensor])

Online sample mean aggregate.

MeanOnlineBatch([tensor])

Online mean measure that updates 1d vector mean from a batch of vectors (2d tensor).

SumOnlineBatch()

Online sum measure.

MeanOnlineLabels([cls])

Keep track of population mean for each unique class label.

VarianceOnline([tensor])

Welford's online algorithm for population mean and variance estimation.

VarianceOnlineBatch([tensor])

Welford's online algorithm for population mean and variance estimation from batches of 1d vectors.

VarianceOnlineLabels()

Keep track of population mean and std for each unique class label.

Data loader with simple API

DataLoader(dataset_cls[, transform, ...])

Data loader with simple API.

Inverse normalizations of data transforms

NormalizeInverse(mean, std)

Undoes the normalization and returns reconstructed images in the input domain.

get_normalize_inverse(transform)

Traverses the input transform, finds a class of Normalize, and returns NormalizeInverse.

get_normalize(transform[, normalize_cls])

Traverses the input transform and finds an instance of normalize_cls.

dataset_mean_std(dataset_cls[, cache, verbose])

Estimates dataset mean and std.

Finding a layer

find_layers(model, layer_class)

Find all layers of type layer_class in the input model and yield them as a generator.

find_named_layers(model, layer_class[, ...])

Find all layers of type layer_class in the input model and yield them as (name, layer) tuples.

Working with batches

input_from_batch(batch)

If the input is a tensor, return it.

batch_to_cuda(batch)

Transfers the batch to CUDA.

clone_cpu(tensor)

Clones a tensor, followed by to CPU transfer.

Miscellaneous

set_seed(seed)

Sets the global seed for PyTorch, Numpy, and built-in random function.

Layer hooks

get_layers_ordered(model, input_sample[, ...])

Returns a list of ordered layers of the input model.

Convert a model to the train or test mode

ModelMode(mode, requires_grad)

Stores the model state with its parameters to be restored later on.

prepare_eval(model)

Sets the model and its parameters to the eval state.

Signal processing and statistics

exponential_moving_average(tensor, window)

Exponential moving average in a sliding window.

peak_to_signal_noise_ratio(signal_orig, ...)

Computes the Peak signal-to-noise ratio between two signals.

compute_sparsity(tensor)

Compute L1 sparsity of the input tensor.

Stubs

OptimizerStub()

An Optimizer stub for trainers that update model weights in a gradient-free fashion.

Constants

mighty.utils.constants.BATCH_SIZE: int = 256

Default batch size.

mighty.utils.constants.MIGHTY_DIR: str

Pytorch-mighty root directory. Defaults to ${HOME}/.mighty.

mighty.utils.constants.DATA_DIR: str

A directory with downloaded datasets. Defaults to ${HOME}/.mighty/data.

mighty.utils.constants.CHECKPOINTS_DIR: str

A directory with checkpoints. Defaults to {HOME}/.mighty/checkpoints.

mighty.utils.constants.DUMPS_DIR: str

A directory with dumped layer activations. Defaults to {HOME}/.mighty/dumps.

mighty.utils.constants.PCA_DIR: str

A directory with PCA pretrained instances that transforms layer activations to lower dimensions to be able to estimate Mutual Information. Defaults to {HOME}/.mighty/pca.

mighty.utils.constants.VISDOM_LOGS_DIR: str

A directory with visdom logs, when a visdom server works in offline mode. Defaults to {HOME}/.mighty/visdom_logs.