gandalfbialy

Untitled

Jun 14th, 2025
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. fig, axes = plt.subplots(nrows=10, ncols=5, figsize=(7, 14))
  2. fig.suptitle("Po 5 przykładowych obrazów z każdej klasy MNIST", fontsize=14)
  3. rng = np.random.default_rng()
  4.  
  5. for digit in range(10):
  6.     idxs = np.where(y_train == digit)[0]
  7.     chosen = rng.choice(idxs, size=5, replace=False)
  8.  
  9.     for col, img_idx in enumerate(chosen):
  10.         ax = axes[digit, col]
  11.         ax.imshow(x_train[img_idx], cmap="gray")
  12.         ax.axis("off")
  13.  
  14. plt.show()
Add Comment
Please, Sign In to add comment