Spaces:
Sleeping
Sleeping
Commit
·
6e6a688
1
Parent(s):
bec1ee5
added animated plot of loss history
Browse files- neural_network/plot.py +16 -9
neural_network/plot.py
CHANGED
@@ -1,15 +1,22 @@
|
|
1 |
-
import matplotlib.pyplot as plt
|
2 |
-
import numpy as np
|
3 |
import seaborn as sns
|
|
|
|
|
4 |
|
5 |
sns.set()
|
6 |
|
7 |
|
8 |
-
def loss_history_plt(loss_history:
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
plt.show()
|
|
|
|
|
|
|
1 |
import seaborn as sns
|
2 |
+
import matplotlib.pyplot as plt
|
3 |
+
from matplotlib.animation import FuncAnimation
|
4 |
|
5 |
sns.set()
|
6 |
|
7 |
|
8 |
+
def loss_history_plt(loss_history: list) -> None:
|
9 |
+
fig, ax = plt.subplots()
|
10 |
+
|
11 |
+
def animate(i):
|
12 |
+
ax.clear()
|
13 |
+
sns.lineplot(
|
14 |
+
x=range(i),
|
15 |
+
y=loss_history[:i],
|
16 |
+
ax=ax,
|
17 |
+
)
|
18 |
+
ax.set_xlabel("Epoch")
|
19 |
+
ax.set_ylabel("Training Loss")
|
20 |
+
|
21 |
+
_ = FuncAnimation(fig, animate, frames=len(loss_history), interval=100)
|
22 |
plt.show()
|