Assignment 5 - Course Project

Cutom Optimizer

    sched = torch.optim.lr_scheduler.OneCycleLR(optimizer, max_lr, epochs=epochs, 

Epoch is the number times that the learning algorithm will work through the entire training dataset. steps_per_epoch should be equal to len(train_loader) / len(batch). Am I right?

Why it is steps_per_epoch=len(train_loader) in the notebook provided?

I had the same issue actually, i just used squeeze, to squeeze the 1 then use matplotlib to plot like I did then use cmap=‘gray’

In my model what happened was i could turn the picture to grayscale with transforms of pytorch but I couldnt plot it using that permute so thats how i used as my way around.

Yee… Would that be a problem?

Lenght of dataloader IS length of dataset devided by batch size. You would be right if there was dataset instead of loader

Now it is clear. Paths in Unix system are written with forward slash home/user/bin, in Windows with back slashes. C:\user\Desktop. You can either hard code it with backslashes or use
os.path.join('brain-mri-images-for-brain-tumor-detection', 'data')
for your dir and for file say
os.path.join('brain-mri-images-for-brain-tumor-detection', 'data', 'file')

1 Like

A post was merged into an existing topic: Share your work : June 22 - June 28

That’s so weird.
I really should see some subfolders if I use os.listdir() for the directory from os.path.join(‘brain-mri-images-for-brain-tumor-detection’, ‘brain_tumor_dataset’) right? But I don’t.
Also, after many runs, the downloaded file is at -5734400.0% -> this seems alarming to me.

A post was merged into an existing topic: Share your work : June 22 - June 28

os.path.join(‘brain-mri-images-for-brain-tumor-detection’, ‘brain_tumor_dataset’) - this will give you just a string but it will ‘adapt’ to whichever platform you use. if you have in your CWD structure like ‘parent-dir-1’, ‘parent-dir-2’, os.listdir('.') will list this two. if you want to see the content of these dirs you are running os.listdir('parent-dir-1') Now, if you go down the tree of your file system you add another argument to os.path. join(), i.e. another name of the child dir/file you want. Take a look at a screenshot, I hope it will become clearer

Here was what I did, my bad if it wasn’t clear :sweat_smile:
When I print data_dir1, I get the directory itself instead of the content (subfolders).
From the descriptions of the dataset, the data is arranged as below:


  • |_____yes
    *** …

  • |_____no
    *** …

Hello Everyone!
I am facing this error. I do not know how to solve it. Please help me.

I really dont understand the concept of “the model learns”. I always thought that it will evaluate everytime.
The model training includes setting the right weights, adjusting the weights or kernels till we get our predictions right.
But when you say that from the training datasets it learns that a specific dataset is a dog or a specific dataset is a cat. It makes less sense. The model does not store this! So how does it learn this bit.

I am getting -ve value predictions for the binary classification problem. Any idea where is the mistake? my train and validation is working fine and showing a decent 75% accuracy.


Here is the prediction code:

how to get the output in the format of 1/0?


I’m stuck. I’m trying it for hours but the accuracy rate still worse. This is the model I’m using.

Then this is what I get when I try to evaluate the data set.

Please help me guys! Thank you!

Hi, am dealing with a dataset with lot of images in different classes but images have different shapes(size). so how can i create a pipeline that resize all images into same size(shape) so i could pass all the image through it??

May I ask what loss function you are using and how you calculate accuracy?

The easiest way? skimage resize would do.

  1. always double-check your data
  2. how do you calculate accuracy?
  3. what’s loss function are you using?
  4. always a good idea to log some outputs of your model when model behaves weirdly, even with basic print() function

Hello guys,

I’ve tried to build a regression model. You can check the notebook here. No matter which loss functions I use or create a feedforward network, the loss does not fall below a certain level of (65k) which is bad. Can anyone help me out to figure out what loss function or ways can I work on this regression? Is this even worth something to put as a project? Any feedback would be helpful


This is what I use. I get it from the 4th lecture.