WilliamWithering

Graph

Dec 15th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. from Results import *
  2. import matplotlib.pyplot as  plt
  3. import numpy as np
  4.  
  5. # Put all the losses in the same array, and get the averaged losses
  6. train_bn = np.array([vgg16_bn_1, vgg16_bn_2, vgg16_bn_3, vgg16_bn_4, vgg16_bn_5])
  7. train_bn = np.mean(train_bn, axis = 0)
  8. scale = np.linspace(0, 30, len(train_bn))
  9.  
  10. # Compute the rolling loss
  11. rolling_bn = [np.mean(train_bn[i:i+100]) for i in range(len(train_bn) - 100)]
  12.  
  13. # Plot
  14. ax = plt.figure().gca()
  15. ax.set_xticks(np.arange(0, 31, 1))
  16. plt.plot(scale, train_bn, label = "Mean of losses on 5 runs")
  17. plt.plot(scale[:-100], rolling_bn, label = "Rolling loss on 100 minibatches")
  18. plt.title("Batch Norm")
  19. plt.grid(axis = 'x', which = 'both' )
  20. plt.xlabel("Epochs")
  21. plt.ylabel("Loss")
  22. plt.legend()
Advertisement
Add Comment
Please, Sign In to add comment