Saving model in fastai v2

Hello there,

I’m new to fastai v2 (not fastaiv1) and this forum so I’m still trying to figure a few things out.
I’ve trained a model and want to save it. In the fastai v2 documentation there is a function called ‘save_model()’. (

The arguments for the function are:

  • file (path)
    -model (I guess the trained learner object)
  • opt

My question is: what is opt?

When I pass the function without specifying opt I get this message (./ is the path, learn is the model I just trained:
save_model('./' , learn)
TypeError: save_model() missing 1 required positional argument: 'opt'

So I was wondering what opt is, as it’s not clear in the documentation.

Thank you in advance for anyone taking their time to answer the question.

hey @lucacontini, opt stands for optimizer (fastai vocab gets tricky sometimes: If you keep with_opt=True it is a required argument.


The better option is'myfname'). This will automatically fill that opt requirement for you. (and uses the API properly)


Thank you! Very helpful

That’s what I ended up doing. Thank you for the reply!