Spaces:
Sleeping
Sleeping
Update plot.py
Browse files
plot.py
CHANGED
@@ -1,26 +1,33 @@
|
|
|
|
1 |
import matplotlib.pyplot as plt
|
2 |
import numpy as np
|
3 |
-
import
|
|
|
4 |
|
5 |
def plot_radar_chart(config):
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
13 |
values += values[:1]
|
|
|
14 |
angles += angles[:1]
|
15 |
|
16 |
fig, ax = plt.subplots(figsize=(5, 5), subplot_kw=dict(polar=True))
|
17 |
-
ax.plot(angles, values,
|
18 |
ax.fill(angles, values, alpha=0.25)
|
19 |
-
ax.
|
20 |
-
ax.
|
21 |
-
ax.
|
|
|
22 |
|
23 |
-
|
24 |
-
plt.savefig(
|
25 |
-
|
26 |
-
|
|
|
|
1 |
+
# plot.py
|
2 |
import matplotlib.pyplot as plt
|
3 |
import numpy as np
|
4 |
+
import io
|
5 |
+
from PIL import Image
|
6 |
|
7 |
def plot_radar_chart(config):
|
8 |
+
# Traits to plot
|
9 |
+
traits = ["layers", "attention_heads", "ffn_dim", "dropout"]
|
10 |
+
values = [
|
11 |
+
config["layers"],
|
12 |
+
config["attention_heads"],
|
13 |
+
config["ffn_dim"] / 512, # Normalize
|
14 |
+
config["dropout"] * 10, # Normalize
|
15 |
+
]
|
16 |
+
# Repeat first value to close the loop
|
17 |
values += values[:1]
|
18 |
+
angles = np.linspace(0, 2 * np.pi, len(traits), endpoint=False).tolist()
|
19 |
angles += angles[:1]
|
20 |
|
21 |
fig, ax = plt.subplots(figsize=(5, 5), subplot_kw=dict(polar=True))
|
22 |
+
ax.plot(angles, values, "o-", linewidth=2)
|
23 |
ax.fill(angles, values, alpha=0.25)
|
24 |
+
ax.set_yticklabels([])
|
25 |
+
ax.set_xticks(angles[:-1])
|
26 |
+
ax.set_xticklabels(traits)
|
27 |
+
ax.set_title("Final Generation Trait Radar", fontsize=14)
|
28 |
|
29 |
+
buf = io.BytesIO()
|
30 |
+
plt.savefig(buf, format="png")
|
31 |
+
buf.seek(0)
|
32 |
+
image = Image.open(buf)
|
33 |
+
return image
|