|
997 | 997 | "source": [
|
998 | 998 | "test_faces = np.asarray(test_faces)\n",
|
999 | 999 | "test_faces = test_faces.reshape(20, 64, 64, 3)\n",
|
1000 |
| - "logits = dbvae.predict(test_faces)\n", |
1001 | 1000 | "y_logit, z_mean, z_logsigma, x_recon = dbvae(test_faces)\n",
|
1002 | 1001 | "loss, class_loss, vae_loss = debiasing_loss_function(test_faces, x_recon, tf.ones((20, 1)), y_logit, z_mean, z_logsigma)\n",
|
1003 | 1002 | "indices = np.argsort(vae_loss, axis=None)\n",
|
1004 | 1003 | "test_faces = test_faces[indices]\n",
|
1005 |
| - "class_loss = class_loss.numpy()[indices]\n", |
| 1004 | + "vae_loss = vae_loss.numpy()[indices]\n", |
1006 | 1005 | "\n",
|
1007 |
| - "\n", |
1008 |
| - "fig, axs = plt.subplots(1, 5)\n", |
| 1006 | + "fig, axs = plt.subplots(1, 5, constrained_layout=True)\n", |
1009 | 1007 | "for i in range(1, 6):\n",
|
1010 | 1008 | " axs[i - 1].imshow(test_faces[- 1 * i])\n",
|
1011 |
| - " axs[i - 1].set_title(round(vae_loss.numpy()[-1 * i], 7))\n", |
| 1009 | + " axs[i - 1].set_title(round(vae_loss[-1 * i], 7))\n", |
| 1010 | + "print(\"Samples with the highest reconstruction loss\")\n", |
| 1011 | + "plt.show()\n", |
1012 | 1012 | "\n",
|
1013 |
| - "fig, axs = plt.subplots(1, 5)\n", |
| 1013 | + "fig, axs = plt.subplots(1, 5, constrained_layout=True)\n", |
1014 | 1014 | "for i in range(5):\n",
|
1015 | 1015 | " axs[i].imshow(test_faces[i])\n",
|
1016 |
| - " axs[i].set_title(round(vae_loss.numpy()[i], 7))" |
| 1016 | + " axs[i].set_title(round(vae_loss[i], 7))\n", |
| 1017 | + "print(\"Samples with the lowest reconstruction loss\")" |
1017 | 1018 | ]
|
1018 | 1019 | },
|
1019 | 1020 | {
|
|
0 commit comments