Synthetic Learner

For quick testing of the training loop and Callbacks

source

synth_dbunch

 synth_dbunch (a=2, b=3, bs=16, n_train=10, n_valid=2, cuda=False)

source

RegModel

 RegModel ()

Same as nn.Module, but no need for subclasses to call super().__init__


source

synth_learner

 synth_learner (n_trn=10, n_val=2, cuda=False, lr=0.001, data=None,
                model=None, loss_func:callable|None=None,
                opt_func=<function Adam>, splitter:callable=<function
                trainable_params>, cbs=None, metrics=None, path=None,
                model_dir='models', wd=None, wd_bn_bias=False,
                train_bn=True, moms=(0.95, 0.85, 0.95),
                default_cbs:bool=True)
Type Default Details
n_trn int 10
n_val int 2
cuda bool False
lr float 0.001 Learning rate
data NoneType None
model callable The model to train or use for inference
loss_func callable | None None Loss function for training
opt_func function Adam Optimisation function for training
splitter callable trainable_params Used to split parameters into layer groups
cbs NoneType None Callbacks
metrics NoneType None Printed after each epoch
path NoneType None Parent directory to save, load, and export models
model_dir str models Subdirectory to save and load models
wd NoneType None Weight decay
wd_bn_bias bool False Apply weight decay to batchnorm bias params?
train_bn bool True Always train batchnorm layers?
moms tuple (0.95, 0.85, 0.95) Momentum
default_cbs bool True Include default callbacks?

source

VerboseCallback

 VerboseCallback (after_create=None, before_fit=None, before_epoch=None,
                  before_train=None, before_batch=None, after_pred=None,
                  after_loss=None, before_backward=None,
                  after_cancel_backward=None, after_backward=None,
                  before_step=None, after_cancel_step=None,
                  after_step=None, after_cancel_batch=None,
                  after_batch=None, after_cancel_train=None,
                  after_train=None, before_validate=None,
                  after_cancel_validate=None, after_validate=None,
                  after_cancel_epoch=None, after_epoch=None,
                  after_cancel_fit=None, after_fit=None)

Callback that prints the name of each event called

Install Utils


source

get_env

 get_env (name)

Return env var value if it’s defined and not an empty string, or return Unknown


source

try_import

 try_import (module)

Try to import module. Returns module’s object on success, None on failure


source

nvidia_smi

 nvidia_smi (cmd='nvidia-smi')
res = nvidia_smi()

source

nvidia_mem

 nvidia_mem ()
nvidia_mem()
['48600', '7982']

source

show_install

 show_install (show_nvidia_smi:bool=False)

Print user’s setup information

- Export