Anki
Colab link: https://colab.research.google.com/github/fastai/fastbook/blob/master/06_multicat.ipynb#scrollTo=f07AU9ac3zP_
Aim: create a (vision) model that can assign multiple (including zero) labels to each item
Setup
Python: CSV to DataFrame
pd.read_csv(path)
FastAI: what does Datasets
do?
Creates a list of tuples by applying a set of transforms to some input data
FastAI: load a DataFrame
into a DataBlock
data_block.<datasets|dataloaders>(data_frame)
Training
PyTorch: module for single-class loss on probabilities
nn.NLLLoss
PyTorch: module for single-class loss on logits
nn.CrossEntropyLoss
PyTorch: module for multi-class loss on probabilities
nn.BCELoss
PyTorch: module for multi-class loss on logits
nn.BCEWithLogitsLoss
PyTorch: module for regression loss
nn.MSELoss
Difference in final layer between single-class and multi-class neural nets
single-class: softmax
multi-class: individual sigmoids
What is the term for the loss typically used in the multi-class classification setting?
Binary cross-entropy
Python: partial function application
new_fn = partial(fn, arg=value, ...)
FastAI: calculate validation metrics without re-training
learner.validate()
Pytorch: get n
values spread uniformly across a range
torch.linspace(start, end, n)
FastAI: visualise batch
dls.show_batch()
FastAI: visualise model output on validation data
learn.show_results()