I am sharing a few advice shared by Jeremy in the Lesson-0 of the fastai course and the introduction section of the book:

  • Commit to complete the course image

  • The actual learning of the book, involves the following components usually:

    • Watching lecture/book
    • Running notebook and Experimentation
    • Reproduce Results
    • Working on a different dataset image
  • Always start with a clean version of the notebook and see what all you remember of the existing lessons, and understand what it is doing

  • Don’t hesitate to ask questions ~ Aman Arora

Let me share a few lists of things I learned over the last week. So let’s get started with the logs:

  • If you have trained any model with fastai, you may have noticed the fine_tune() method. So even setting fine_tune(0) run over the dataset once(one epoch). But why? I didn’t notice that until someone asked this question

Since you look at fine_tune() method you will realize the freeze_epochs is set as one by defaults, and epochs you passed in this case is set as zero


  • Justin Hougston answered: on what is the difference between fine_tune and fit_one_cycle method:

From my understanding - in this example, we are defining a pre-trained cnn learner (which is resnet34), and then calling fine_tune() on that model (with pre-trained weights). The. .fine_tune() takes in a few params, the first being number of epochs. So in your code above, we are explicitly saying to run through each item in the dataset once. Interestingly enough, the fine_tune actually re-uses .fit_one_cycle (which is super cool in it of itself) in addition to some unfreezing and freezing of weights. (thread discussing the difference here)


  • What is the secret sauce behind the beautifully formatted doc function in nbdev? Kevin Bird explains:


  • In jupyter notebooks you can use ? mark to see the function definition and ?? to see the source code. It’s interesting to see how well fastai library is written, with short functions of code wherever I explored it.

  • untar_data() function is available for downloading datasets. The datasets are being downloaded in fastai folder, and you can look inside the dataset, by going to that particular path provided by the pathlib module. In the below example, I am opening the URLs.adult dataset in jupyter notebook and explore the csv file using pandas.


On using more features, I was able to get better accuracy than the example provided in the book:


  • In Chapter 2, in the process of downloading images from the internet. I was not interested in using Azure keys as provided by docs. So I found an alternative method by using duckduckgo as mentioned in the book website. The fastbook method for searching duck duck go was not working and it was throwing an error:
AttributeError                            Traceback (most recent call last)
<ipython-input-10-fcb0d9b3a15b> in <module>()
----> 1 urls = search_images_ddg('grizzly bear')
      2 len(urls),urls[0]
/usr/local/lib/python3.7/dist-packages/fastbook/__init__.py in search_images_ddg(term, max_images)
     55     assert max_images<1000
     56     url = 'https://duckduckgo.com/'
---> 57     res = urlread(url,data={'q':term}).decode()
     58     searchObj = re.search(r'vqd=([\d-]+)\&', res)
     59     assert searchObj
AttributeError: 'str' object has no attribute 'decode'

The error can be easily solved by remove decode() function in line no 57. Since the PR for that changes has not yet been merged in fastai repo, I used DuckDuckGoImages package for downloading images with the below code:


  • Since deciding on a GPU server is an important thing to do at first. For the time being, I am planning to use the GPUs provided by Kaggle and Google Colab. Also locally I have set up notebooks with jupyterlab for browsing and looking into source code when notebooks are being run on the server.

Relevant links for this week ➡️: