A fastai Learner from Scratch
Data
Dataset
Module and Parameter
Simple CNN
Loss
Learner
Callbacks
Scheduling the Learning Rate
Conclusion
Questionnaire
tip: Experiments: For the questions here that ask you to explain what some function or class is, you should also complete your own code experiments.
What is
glob?How do you open an image with the Python imaging library?
What does
L.mapdo?What does
Selfdo?What is
L.val2idx?What methods do you need to implement to create your own
Dataset?Why do we call
convertwhen we open an image from Imagenette?What does
~do? How is it useful for splitting training and validation sets?Does
~work with theLorTensorclasses? What about NumPy arrays, Python lists, or pandas DataFrames?What is
ProcessPoolExecutor?How does
L.range(self.ds)work?What is
__iter__?What is
first?What is
permute? Why is it needed?What is a recursive function? How does it help us define the
parametersmethod?Write a recursive function that returns the first 20 items of the Fibonacci sequence.
What is
super?Why do subclasses of
Moduleneed to overrideforwardinstead of defining__call__?In
ConvLayer, why doesinitdepend onact?Why does
Sequentialneed to callregister_modules?Write a hook that prints the shape of every layer's activations.
What is "LogSumExp"?
Why is
log_softmaxuseful?What is
GetAttr? How is it helpful for callbacks?Reimplement one of the callbacks in this chapter without inheriting from
CallbackorGetAttr.What does
Learner.__call__do?What is
getattr? (Note the case difference toGetAttr!)Why is there a
tryblock infit?Why do we check for
model.traininginone_batch?What is
store_attr?What is the purpose of
TrackResults.before_epoch?What does
model.cudado? How does it work?Why do we need to check
model.traininginLRFinderandOneCycle?Use cosine annealing in
OneCycle.
Further Research
Write
resnet18from scratch (refer to <<chapter_resnet>> as needed), and train it with theLearnerin this chapter.Implement a batchnorm layer from scratch and use it in your
resnet18.Write a Mixup callback for use in this chapter.
Add momentum to SGD.
Pick a few features that you're interested in from fastai (or any other library) and implement them in this chapter.
Pick a research paper that's not yet implemented in fastai or PyTorch and implement it in this chapter.
Port it over to fastai.
Submit a pull request to fastai, or create your own extension module and release it.
Hint: you may find it helpful to use
nbdevto create and deploy your package.