Lecture 2: Working with Images & Logistic Regression

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

Notebooks :

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

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 to this thread to ask questions. Before asking, scroll through the thread and check if your question (or a similar one) is already present. If yes, just like it. We will give priority to the questions with the most likes. The rest will be answered by our mentors or the community. 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:


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?


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


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):


    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:
outputs = model(images)

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


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.
I think this topic about learning rate scheduler might also be covered later in the course.


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