Lecture 2: Working with Images & Logistic Regression

Session Links
English: https://youtu.be/uuuzvOEC0zw
Hindi: https://youtu.be/qmzgJvVP9XA

Lecture Date and Time: November 28, 2020,
English: 9 PM IST/8.30 AM PST | Add to calendar (Google)
Hindi: 11 AM IST | Add to calendar (Google)

Notebooks :

  1. Logistic Regression: https://jovian.ai/aakashns/03-logistic-regression
  2. Logistic Regression minimal starter: https://jovian.ai/aakashns/mnist-logistic-minimal
  3. Linear Regression minimal starter: https://jovian.ai/aakashns/housing-linear-minimal

What to do after the lecture?

  • Run the Jupyter notebooks shared above (try other datasets)
  • Ask and answer questions on this topic (scroll down)
  • Start working on Assignment 2 - Train Your First Model

Asking/Answering Questions:

Reply on this thread to ask questions during and after the lecture. Before asking, scroll through the thread and check if your question (or a similar one) is already present. If yes, just like it. During the lecture, we’ll answer 8-10 questions with the most likes. The rest will be answered on the forum. If you see a question you know the answer to, please post your answer as a reply to that question. Let’s help each other learn!

too fast for beginner … but that’s ok … I need to refresh maths and revisit session multiple times :slight_smile:

5 Likes

Is there a method to choosebatch size?

what are things to note when we do for other image datsets

1 Like

how to do lebeling for unlabel image datasets

1 Like

How can we change the learning rate at the point where the model’s accuracy starts becoming constant? Something like adaptive learning rate?

2 Likes

Why during evaluation time we don’t call model.eval() and torch.no_grad?

Helo aakash…
Can I kindly have the recorded video for lecture 2…??

1 Like

@hemanth, if we want to post our project on linear regression and ask for people’s opinion and advises on it,for this in which group do i post my project?

Thank you for pointing this out, @sathi-satb!
I have created a new thread which can be found here:

Hey @agatha-l, the session links are given in the description above!

as @aakashns was calling fit function for 5 5 epochs, and was printing result of each iteration, from there we can figure out whether our accuracy is getting constant, then we decrease learning rate for next call of fit function.

the kernel dies as soon as i do plt.imshow() in my jupyter notebook

2 Likes

Yeah, this sounds good however, we will have to manually keep a check on this stagnating accuracy and call a fit function. I was wondering if there’s any function pre built in torch that keeps a check on the accuracy for it to be constant in n epochs and reduces/ increases the learning rate. We can surely write one of our own, but just want to know it there’s one already. This will help when there are 50+ epochs.

class MnistModel(nn.Module):

def __init__(self):

    super().__init__()

    self.linear = nn.Linear(input_size, num_classes)

    

def forward(self, xb):

    xb = xb.reshape(-1, 784)

    out = self.linear(xb) 

    # self.linear will call self.linear function which is available in __init__

    # 

    return out

model = MnistModel()

for images, labels in train_loader:
print(images.shape)
outputs = model(images)
break

how do we ensure that the below line, automatically call forward function?

outputs = model(images)

we know, a function wont execute until we call it, with above line, how forward function will execute? please help me to understand

2 Likes

There are differnet learning rate schedulers, one of this is one cycle learning rate scheculer in which the learning rate gradually increases upto 30% of epoch and then continue to decrease till the last epoch. Here I link a blog post related to it.
https://towardsdatascience.com/learning-rate-scheduler-d8a55747dd90
I think this topic about learning rate scheduler might also be covered later in the course.

2 Likes

Don’t worry @iamsusmita if you need any help or facing any doubt feel free to work together with me and many others here. :slight_smile: At the beginning, it seems tough but as you mould yourself into the process it becomes easier and remembers you are not alone

I don’t there is official support for this. It’s good to do it manually, changes in batchsize can also affect the performance of the model.

1 Like

There can be many points to note, you will have to gain them by developing intuition based on experiments, might be difficult to convey without context . I’ll list some down below

  • Image size
  • Object size
  • Model limitations/ Hardware limitations which can lead to Out of memory errors
  • Noisy images in datasets
  • Certain Loss functions for certain type of applications.
  • If its for a classification dataset you can just simply organize data in a different folder having the label name.
  • If its for multi-object classification, you can consider having a CSV with 2 columns [image_path, classes]
    …so on. Check them out based on the application you can find of a lot of examples in Kaggle datasets and how others do the labeling.
1 Like