Lecture 1 - PyTorch Basics & Linear Regression

I’m getting this error as well, along with “The ordinal 961 could not be located in the dynamic link library”.

Thanks for the great session. I’m already looking forward to next weeks lecture. I think a few of us are currently working on the assignments. Binder is struggling hard :sweat_smile:


Why is squared loss used as opposed to the absolute value?

You could use the absolute value as well, although squaring the loss tends to exaggerate the predictions with greater losses. For instance, a loss value of 2 would become 4 when squared, and a loss value of 3 would become 9 when squared. The larger a loss is, the more exaggerated it becomes; that way, it becomes easier to spot which predictions are causing the bulk of the errors and hence which weights need to be adjusted accordingly.



I am getting an error when trying to run it using Binder .

can some help me in that ?

Thanks for this great course .This is the best ML lecture for beginners that I have attended so far.Great and simple explanation @aakashns

Try running it on colab

1 Like

M also getting the same error can some one help ?

At the same time, if the difference between prediction and desired output falls below 1, the loss starts to become a bit less useful, as squaring anything below 1 causes the number to become even smaller (and providing less information on how to change the weights). In this setting it was OK, because the numbers were usually above 1. But I’ve noticed, when working for example with normalized images (with colors inside 0-1 range or -1 to 1), MSE loss starts to struggle with converging toward minima. This can become a problem when working with a sigmoid or tanh activation function.

When the gradient is negative we increase the values of the weight by adding a portion of the gradient to the weights and when the gradient is positive we decrease the value of the weights by subtracting a portion of the gradient from the weights. Is my statement correct ?

1 Like

Where you able to resolve this issue, as I still have the same.

For anyone struggling with the online notebooks it may be worth a shot running them locally on your machine. I’ve thrown together a quick guide on how I installed on Windows using VSCode, if anyone is interested.


conda in windows is not very stable with Pytorch and specially when we needed to use GPUs, which is going to be the case for the next lectures. It has numerous compatibility issues with the cuda libraries necessary to make it work.

May I suggest you guys not to run things locally, otherwise you can spend a lot of time trying to configure and make things work instead of focusing on the code and the concepts from the lecture. I just forked the notebooks and I am running the notebooks right here on Jovian, which uses Binder as a kernel where things are already configured.

Just a suggestion from having spend numerous hours trying to run things on Windows.


Hello, I just finished going through the first note book 01-pytorch-basics and I was trying some stuff when I encountered this warning. I am just a beginner in pytorch.

What I did upto this point:

  • The next thing I did was to follow the github link and found this solution.

Use .retain_grad() if you want the gradient for a non-leaf Tensor. Or make sure you have the leaf Tensor if your have a non-leaf Tensor by mistake.

  • Then I searched about leaf and non leaf tensors and I could not find enough information, would be great if someone helps me with this also.

Steps to reproduce:

Warning message:

/srv/conda/envs/notebook/lib/python3.7/site-packages/torch/tensor.py:746: UserWarning: The .grad attribute of a Tensor that is not a leaf Tensor is being accessed. Its .grad attribute won’t be populated during autograd.backward(). If you indeed want the gradient for a non-leaf Tensor, use .retain_grad() on the non-leaf Tensor. If you access the non-leaf Tensor by mistake, make sure you access the leaf Tensor instead. See github.com/pytorch/pytorch/pull/30531 for more informations.
warnings.warn("The .grad attribute of a Tensor that is not a leaf Tensor is being accessed. Its .grad "


About questions at “Further Reading”

I don’t know if answer could be:
“you can’t backward on many non-leaf tensors”, because “grad can be implicitly created only for scalar outputs” (what that means, I neither know)

So a solution could be execute => y.sum().backward()

But, is this what you expect? I’m trying to draw on this end questions.

How do you know if i watched the lecture 100% ?

what to do when binder take a long time to start an environment?

Yes! To minimise the loss as evident from the weight-loss graph.

I got it to work by running this command into the environment:
conda install -c defaults intel-openmp -f

Also make sure Conda is updated to the latest version.


It’s all about being genuine. If you haven’t watched lecture. Your won’t be able to work on assignments if you’re a beginner . One thing leads to another @anis-bensaci8

It is for us to learn. That’s why its free !!!
Getting only certificate doesn’t mean anything if you can’t apply the skills.


That should not cause an issue @edsenmichaelcy. Depending on your operating system, some underlying dependencies of PyTorch/Jupyter may not get installed on your system. But the notebook should work

Hi @alvertosk84 and @danny thanks for reporting your errors. Try the solution shared by @Luay conda install -c defaults intel-openmp -f

@jazz215 There’s no confirmation. Also, we’ve made marking attendance optional for lecture 1. cc @viratsatheesh29