-2

I have a training.log file which contain

epoch,acc,loss,val_acc,val_loss

0,0.3362708558291825,1.7554432798434318,0.32878239064221265,1.9248546749544395

1,0.44641053328276503,1.4846536312246443,0.4288102535608254,1.6995067473539371

2,0.48078999617260126,1.3865143429660396,0.5075229869044302,1.34374766792883

3,0.5082378348294684,1.315985157798793,0.5161604904205097,1.2767660616831913

4,0.5180953707906859,1.2740170841302745,0.5090554472080809,1.3178076734115036

5,0.5380194364147063,1.2369382053114344,0.5238227918972441,1.286055219077107

Mushtaq Patel
  • 16
  • 1
  • 6

2 Answers2

2

Quite simple using pandas and pyplot :)

Here's some sample code:

import pandas as pd
import pylab as plt

# Create dataframe
file_name = "training.log"
df = pd.DataFrame.from_csv(file_name)
df.plot()
plt.show()
Bob de Graaf
  • 2,630
  • 1
  • 25
  • 43
1

1.Let tensorboard do the task of plotting by following below steps Type below command in the set environment

tensorboard --logdir=path/to/log-directory

Once TensorBoard is running, navigate your web browser to localhost:6006 to view the TensorBoard.You can generate log file just by mentioning the callback method in fit method while training your model. Mostly I prefer a tensorboard way keras callback How do I use the Tensorboard callback of Keras?

  1. Another way is access all parameters from the log file and use matplotlib Read log file and put appropriate values in below code snippet

    Plot the Loss Curves

    plt.figure(figsize=[8,6])
    plt.plot('access loss value from log file','r',linewidth=3.0)
    plt.plot('access val_loss from log file','b',linewidth=3.0)
    plt.legend(['Training loss', 'Validation Loss'],fontsize=18)
    plt.xlabel('Epochs ',fontsize=16)
    plt.ylabel('Loss',fontsize=16)
    plt.title('Loss Curves',fontsize=16)
    

Plot the Accuracy Curves

plt.figure(figsize=[8,6])
plt.plot('access acc value from log file','r',linewidth=3.0)
plt.plot('access val_acc from log file,'b',linewidth=3.0)
plt.legend(['Training Accuracy', 'Validation Accuracy'],fontsize=18)
plt.xlabel('Epochs ',fontsize=16)
plt.ylabel('Accuracy',fontsize=16)
plt.title('Accuracy Curves',fontsize=16)
devesh
  • 618
  • 6
  • 26