How to visualize the accuracy and training loss of a trained model of pytorch?

I have a trained model(my_model.pth) in pytorch, I want to visualize its accuracy and loss in a graph form. How can I do that?

I think you could use visdom to achieve it.:wink:

Is it possible even if I finished my training process cause if I will retrain it, it will take a long time.

If you trained your model without any logging mechanism there is no way to plot it now. You can always evaluate your model in the test set and report accuracy (or other metrics) using visdom (as @MariosOreo stated) or tensorboardX.

But if you want to plot training loss and accuracy curves I’m afraid you can only do it if you stored those numbers somewhere.

1 Like

Does this mean I should save my log files to a text file and use that text file for plotting?

Yes. Either save log files, or save CSV/JSON files with loss per epoch per batch, or save event files with tensorboardX or visdom.

There is no way to recover stats after training if they were not saved in the first place.

1 Like in line 49 there is my loss. Is this the one I should save?

I was trying to save this to a text file like this:
f = open(“logfile.txt”, “a”)
and at line 49 like this:
loss = f.write(‘log.txt’, ‘a’).

It gives me error, it says "’_io.TextIOWrapper’ object has no attribute ‘training_data’