Save Learner attributes like recorder

I’d like to save my Learner, but not just its weights.
I want to be able to call learn.recorder.plot_losses() after for instance image, get top_losses, etc.

Is it possible? Because if I do and then learn.load(), I get the following error when I try to call learn.recorder.plot_losses() :

  • AttributeError: ‘Learner’ object has no attribute ‘recorder’

It is not exactly what you want but you can use callbacks.csv_logger to save your losses after train.

You can find how to use it here:

Not sure but I think learn.load() just load the weights.

1 Like

Thanks @dhoa,
When i try

  • learn = Learner(data, simple_cnn((3, 16, 16, 2)), metrics=[accuracy, error_rate], callback_fns=[CSVLogger])
    i get the following error:
  • NameError: name ‘CSVLogger’ is not defined

Do you know why?


Try callbacks.csv_logger ? I remember got this problem too.

Hope that helps

It works, thanks @dhoa.
But i still want to be able to call any method of learn after, since i’m using a server to train, and i don’t have a visual environement (I can just download outputs from the python code). If anyone knows how to save everything (including recorder), please share with us.


In any plot, you can pass return_fig=True and then use matplotlib’s .savefig or .save function to save it locally. (I can’t 100% recall which one). It’s not quite what you’re wanting but atleast you can save the graphs.

Hope it helps.

1 Like

Hi, for those who want to directly append the CSV logger to the learner’s callback functions, here is the line :


If you want to append futur training sessions logs to your existing file, don’t forget the argument append=True. Hence, the line should look like this :

learner.callback_fns.append(partial(callbacks.CSVLogger, append=True))

I’ve just checked the exact synthax a minute ago. :slight_smile:

Hi ,

I’m getting issues while the accuracy/loss plot And I also want t check my final accuracy of the model.

How can I fix that?