Training Your First Model Flashcards
Main steps in training a basic image classifier?
Import libraries, load data, define labelling function, create DataLoaders, define model, training
Code to create a model in a computer vision task?
learn = vision_learner(dls, resnet34, metrics=error_rate)
What is dls (DataLoaders) object?
Contains both training and validation data and specifies which data is used in training
What is ImageNet?
> 14M photos, >21k classes. dataset used for pre-training image-based NN
Can you solve non-image tasks using image classifiers?
Yes, if the data can be transformed to an image reasonably well
from fastai.vision.all import *
Imports everything (*) from the fastai.vision library
First line of code for all fastai notebooks
pip install fastbook
path = untar_data(URLs.PETS)/’images’
- Downloads (compressed) dataset from the URL stored in URLs.PETS
– Unpacks the dataset and returns the local path to the dataset
– In particular, the ‘images’ subfolder contains the images of the dataset
fdef is_cat(x): return x[0].isupper()
Defines labelling function, Here: If the file name starts with a capital letter (e.g., “Abyssinian_1.jpg”), it contains a cat
learn = vision_learner(dls, resnet34, metrics=error_rate)
– Creates a vision learner, i.e., we use images as inputs
– Specifies the data (dls), architecture (resnet34) and metric (error_rate)
– ResNets achieve state-of-the art results
– resnet: “Residual Neural Network”, specific model architecture
– 34 in resnet34 refers to the number of layers of the network (alternatives: 18, 50, 101 and 152)
learn.fine_tune(1)
– This fits the model (more precisely: fine-tunes it)
– Per default (shown here):
– One epoch only on randomly initialized model head
– Number of epochs requested (here: 1) to fit the entire model, but updating weights of later layers faster than earlier layers
One complete pass through the dataset
Epoch
Advantages of Transfer Learning
Faster Convergence, Reduced Data Requirements, Better Performance, Reduced Computational Cost
Which ML tasks can be transformed to image classification?
Time Series Classification, Text Classification, Genomic Sequence Analysis, Sensor Data Analysis, Graph Data Analysis, Tabular Data Classification
Name five areas where deep learning is now the best tool in the world
Computer Vision, Natural Language Processing (NLP), - Speech Recognition, Autonomous Vehicles, Healthcare and Drug Discovery