Getting NameError: name 'partial' is not defined

When I run opt_fn = partial(optim.Adam, betas=(0.8, 0.99)) in the imdb.ipynb notebook here: https://github.com/fastai/fastai/blob/master/courses/dl2/imdb.ipynb. I am getting the above error. I am not able to know which module partial belongs to so that I can import it.

Also, can someone tell me where I can get all the imports required for the imdb.ipynb notebook above

Hello there,
The “partial” function is from package “functools”.
It is used when you don’t want to provide all of the parameters of a function at once.
So import partial this way and try again:

from functools import partial

1 Like

from fastai.vision.all import partial worked for me