Part 1 Lesson 1 -- Men vs. Women


(Johnson) #1

I am trying my hand at Lesson 1 substituting Men vs. Women in place of Dogs vs. Cats. I have run everything from lesson1.ipynb on a new file on my paperspace machine and seem to have a solid 80% accuracy rate using only 100 total images (60 Men && 60 Women Train, 20 Men && 20 Women Valid, 20 Men && 20 Women Test).

My question is what did I do wrong with the learning rate. In [49] : learn.sched.plot_lr() on my notebook shows a straight line. There is no slope like shown In [36] lesson1.ipynb. Further, my In [50]: learn.sched.plot() shows nothing. There is no plotted line (loss vs LR). This has me now questioning my supposed 80% accuracy. It doesnt make sense to me after watching Lesson 1 to have any accurate model if I cannot discern an accurate-ish learning rate.

I posted an image of my workbook on imagebin:


(Carlos Vouking) #2

I think this is due to the batch size (bs) as training on small size datasets. Not explicitely setting a bs for your data gets you to train your model on a default batch size of 64.
Try reducing the batch size like so:
* data = ImageClassifierData.from_paths(path, tfms=transforms_from_model(arch, sz), bs=10)
and see what comes out.

Hope it gets better.


(Johnson) #3

Thank you so much for your help! That makes sense to shrink the batch size! It has also given me a curve on the learning rate scheduler. However, the validation loss x learning rate (log) is still empty?


(Carlos Vouking) #4

Note quite sure, but Can you try running your code in this order:

  • lrf = learn.lr_find()

  • learn.sched.plot()

  • learn.sched.plot_lr()


(Johnson) #5

Thank you for your time @StCarl. Unfortunately, I got the same thing. Something else I recall from Jeremy’s lesson was his lrf stopped at 75% as it had finished improving. Mine seems to go all the way to 100% Hmmm…


(Carlos Vouking) #6

Hi @theyear2000, this link might help:
Lesson 1: Choosing a learning rate doesn't work on my dataset


(Johnson) #7

@StCarl thank you so much for the help. That did it! I started playing around with the batch size lowering it until I found a sweet spot that raised my accuracy to 88%.

data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz), bs=4)

I really appreciate your time.


(Carlos Vouking) #8

Good to hear that. How does learn.sched.plot () look like?


(Johnson) #9


(Johnson) #10

This was addressed as a question In Part 1, Lesson 3 at time 1hr 59min in case it helps anyone in the future…


#11

Something else you can try and see if it’ll increase the accuracy is to extract the faces from the images and run your model on the faces themselves.


(Johnson) #12

Interesting idea! Do you mean add the extracted faces to the existing data set or replace the existing data with the extracted faces? Thanks for the heads up!