lightning

Functions and classes which interface with pytorch_lightning

This functionality is WIP.

See scpc for a working example.

raises ImportError:

If pytorch_lightning is not installed.

class pydrobert.torch.lightning.LitDataModule(params, num_workers=None, pin_memory=None)[source]

An ABC handling DataLoader parameterizations and partitions for lightning

property num_workers

the number of parallel workers in a dataloader

If initially unset, the value will be populated during setup() based on the number of CPU cores on the node.

Type:

Optional[int]

property pin_memory

whether to pin memory to the cuda device

If initially unset, the value will be populated during setup() based on whether the trainer’s accelerator is on the GPU.

Type:

Optional[bool]

class pydrobert.torch.lightning.LitDataModuleParams(*, common, predict, predict_dir, prefer_split, test, test_dir, train, train_dir, val, val_dir, name)[source]

Base class LitDataModule parameters

pclass

alias of Parameterized

class pydrobert.torch.lightning.LitDataModuleParamsMetaclass(name, bases, dict_)[source]

ABC for LitDataModuleParams

class pydrobert.torch.lightning.LitSpectDataModule(data_params, batch_first=False, sort_batch=False, suppress_alis=True, tokens_only=True, suppress_uttids=None, shuffle=None, num_workers=None, pin_memory=None, warn_on_missing=True, on_uneven_distributed='raise')[source]

A LitDataModule for SpectDataLoaders

property batch_size

training batch size

This property is just the value of self.params.train_params.batch_size. It is exposed in case auto_scale_batch_size is desired.

Type:

int

property feat_size

feature vector size

Alias of num_filts.

Type:

int

get_info_dict_value(key, default=None)[source]

Get a value from the info dict

The info dict is gathered in setup() if params.info_path is not None.

max_ali_class()[source]

int: the maximum token id in the ali/ subdirectory (usually of training)

Determined in setup() if params.info_path is not None.

property max_ref_class

The maximum token id in the ref/ subdirectory (usually of training)

Corresponds to the

property num_filts

size of the last dimension of tensors in feat/

Determined in setup() if params.info_path is not None.

Type:

int

pclass

alias of LitSpectDataModuleParams

property vocab_size

vocabulary size

Alias of max_ref_class + 1.

Type:

int

class pydrobert.torch.lightning.LitSpectDataModuleParams(*, info_path, mvn_path, common, predict, predict_dir, prefer_split, test, test_dir, train, train_dir, val, val_dir, name)[source]

Parameters for LitSpectDataModule

pclass

alias of SpectDataLoaderParams