Reputation: 3187
I have used Keras before, and then I plotted the training and validation accuracy of datasets this way—
plt.plot(history.history['accuracy'])
plt.plot(history.history['val_accuracy'])
I'm currently learning fastai, and have already plotted training and validation losses. But I don't know how to plot validation accuracy and training accuracy.
learn.recorder.plot_losses()
Would anyone please help?
Upvotes: 4
Views: 7403
Reputation: 7077
Post here just for people who are using the latest FastAI version 2.
The aforementioned methods are out of date and was for Fast AI version 1.
For the latest version, you should use a Callback with fit method:
learn.fit_one_cycle(10, slice(5e-3,5e-2),cbs=[ShowGraphCallback()])
Here is the document
The benefit of using this new callback for plot the train validation metrics is it happens directly after each epoch of training and validation, no need for a separated line of code.
Upvotes: 4
Reputation: 442
Check out: https://forums.fast.ai/t/plotting-metrics-after-learning/69937/3
The function plot_metrics() by Ignacio Oguiza is detailed there. Without it, you'll get an error 'Learner' object has no attribute 'plot_metrics'
Once implemented, you can call plot_metrics() as Sirynka has mentioned:
learn.recorder.plot_metrics()
And you may get some nice charts:
Upvotes: 4
Reputation: 61
learn.recorder.plot_metrics()
will plot all the metrics that you'v specified in
learn = cnn_learner(data, models.resnet34,
metrics=[accuracy, error_rate])
Upvotes: 4