NameError: name 'init_params' is not defined

I am currently on Lesson 3 (Chapter 4 Notebook) and I am trying to initialize my parameters with init_params to assign weights and biases. I keep getting the “NameError: name ‘init_params’ is not defined” error though.

Is there anyone else getting this problem?
Does anyone know of a solution to this or something I am doing wrong (I tried copy and pasting from the official notebook and it doesn’t seem to work either)?

Also, I am a complete beginner to FastAI and DL and running the notebook on Google CoLab. Thanks for the help in advance :blush:

2 Likes

There’s a cell under the section The MNIST Loss Function with this:

def init_params(size, std=1.0): return (torch.randn(size)*std).requires_grad_()

Run that cell first.

2 Likes

It works, thanks so much for the help! :slight_smile:

1 Like