lncrnapy.utils

Constants and supporting objects for lncrnapy.

lncrnapy.utils.CLIP_NORM = 1.0

Maximum L2-norm of gradients (all above are clipped) (default is 1.0).

lncrnapy.utils.DEVICE = device(type='cpu')

Torch device object to use for tensor operations (GPU/CPU) Defaults to torch.device(‘cuda’) if available, else defaults to CPU.

lncrnapy.utils.NUC_TO_4D = {'A': tensor([1., 0., 0., 0.]), 'B': tensor([0.0000, 0.3333, 0.3333, 0.3333]), 'C': tensor([0., 1., 0., 0.]), 'D': tensor([0.3333, 0.0000, 0.3333, 0.3333]), 'G': tensor([0., 0., 1., 0.]), 'H': tensor([0.3333, 0.3333, 0.0000, 0.3333]), 'K': tensor([0.0000, 0.0000, 0.5000, 0.5000]), 'M': tensor([0.5000, 0.5000, 0.0000, 0.0000]), 'N': tensor([0.2500, 0.2500, 0.2500, 0.2500]), 'R': tensor([0.5000, 0.0000, 0.5000, 0.0000]), 'S': tensor([0.0000, 0.5000, 0.5000, 0.0000]), 'T': tensor([0., 0., 0., 1.]), 'V': tensor([0.3333, 0.3333, 0.3333, 0.0000]), 'W': tensor([0.5000, 0.0000, 0.0000, 0.5000]), 'Y': tensor([0.0000, 0.5000, 0.0000, 0.5000])}

Mapping from nucleotide indicator to 4D_DNA representation, which is the format suitable for convolutional neural network layers.

lncrnapy.utils.TOKENS = {'CLS': 1, 'MASK': 0, 'PAD': 3, 'SEP': 2, 'UNK': 4}

Look-up table of special tokens and their associated values. Note that we set BPE to assume that MASK=0, hence this value should not be changed.

lncrnapy.utils.change_device(device)

Safely change PyTorch device, also moves certain constant variables contained within lncrnapy.utils to the specified device.

lncrnapy.utils.freeze(model, unfreeze=False)

(Un-)Freezes all weights in specified model.

lncrnapy.utils.progress

Yields progress bar if tqdm library is installed.

lncrnapy.utils.watch_progress(on=True)

Switches on/off the tqdm progress indicator around large for loops.