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

(Amir Mohammad Salehoof) #2

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