-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviz_utils.py
55 lines (47 loc) · 1.41 KB
/
viz_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import matplotlib.pyplot as plt
def plot_losses(history, path_save=None, show_val=True):
plt.plot(history["loss_train"], label="train")
if show_val:
plt.plot(history["loss_val"], label="val")
plt.grid()
plt.title("Loss vs. epochs")
plt.xlabel("Epochs")
plt.ylabel("Loss")
plt.legend()
if path_save is not None:
plt.savefig(path_save)
plt.show()
def plot_costs(history, path_save=None, show_val=True):
plt.plot(history["cost_train"], label="train")
if show_val:
plt.plot(history["cost_val"], label="val")
plt.grid()
plt.title("Cost vs. epochs")
plt.xlabel("Epochs")
plt.ylabel("Cost")
plt.legend()
if path_save is not None:
plt.savefig(path_save)
plt.show()
def plot_accuracies(history, path_save=None, show_val=True):
plt.plot(history["accuracy_train"], label="train")
if show_val:
plt.plot(history["accuracy_val"], label="val")
plt.grid()
plt.title("Accuracy vs. epochs")
plt.xlabel("Epochs")
plt.ylabel("Accuracy")
plt.legend()
if path_save is not None:
plt.savefig(path_save)
plt.show()
def plot_lrs(history, path_save=None):
plt.plot(history["lr"], label="lr")
plt.grid()
plt.title("Learning rate vs. epochs")
plt.xlabel("Epochs")
plt.ylabel("Learning rate")
plt.legend()
if path_save is not None:
plt.savefig(path_save)
plt.show()