-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewer.py
More file actions
34 lines (24 loc) · 749 Bytes
/
Copy pathviewer.py
File metadata and controls
34 lines (24 loc) · 749 Bytes
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
import numpy as np
import matplotlib.pyplot as plt
from nn_from_scratch.dataset import Dataset
def plot(images: np.ndarray, labels: np.ndarray, indices: list):
_, axes = plt.subplots(1, 5, figsize=(10, 6))
for n in range(0, len(indices)):
image = images[:, n].reshape(28, 28)
label = labels[n]
index = indices[n]
ax = axes[n % 5]
ax.imshow(image, cmap="gray")
ax.set_title(f"{label}")
ax.set_xlabel(f"Id {index}")
ax.set_xticks([])
ax.set_yticks([])
plt.tight_layout()
plt.show()
def main():
dataset = Dataset(split="train")
dataset.extract()
X, Y, indices = dataset.sample(5)
plot(X, Y, indices)
if __name__ == "__main__":
main()