Skip to content

Commit

Permalink
Merge pull request #39 from invrs-io/nb
Browse files Browse the repository at this point in the history
Tweak loss plots
  • Loading branch information
mfschubert authored Oct 27, 2023
2 parents aa3919b + 165370f commit 11338ec
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion notebooks/ceviche_challenge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"plt.ylabel(\"Loss value\")\n",
"plt.subplot(122)\n",
"plt.plot(step, distance_to_target)\n",
"plt.plot(step[mask], distance_to_target[mask], \"bo-\")\n",
"plt.plot(step[mask], distance_to_target[mask], \"bo\")\n",
"plt.xlabel(\"Step\")\n",
"plt.ylabel(\"Distance to target\")\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/diffractive_splitter_challenge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"plt.ylabel(\"Loss value\")\n",
"plt.subplot(122)\n",
"plt.plot(step, distance_to_target)\n",
"plt.plot(step[mask], distance_to_target[mask], \"bo-\")\n",
"plt.plot(step[mask], distance_to_target[mask], \"bo\")\n",
"plt.xlabel(\"Step\")\n",
"plt.ylabel(\"Distance to target\")\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/metagrating_challenge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"plt.ylabel(\"Loss value\")\n",
"plt.subplot(122)\n",
"plt.plot(step, distance_to_target)\n",
"plt.plot(step[mask], distance_to_target[mask], \"bo-\")\n",
"plt.plot(step[mask], distance_to_target[mask], \"bo\")\n",
"plt.xlabel(\"Step\")\n",
"plt.ylabel(\"Distance to target\")\n",
"\n",
Expand Down
20 changes: 19 additions & 1 deletion notebooks/photon_extractor_challenge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,22 @@
"metadata": {},
"outputs": [],
"source": [
"# Plot the loss and efficiency vs. step.\n",
"# Plot the loss vs. step, and the `distance_to_target`. When the distance is\n",
"# zero or negative, the challenge is considered to be solved.\n",
"step = onp.arange(len(loss_values))\n",
"distance_to_target = onp.asarray(distance_values)\n",
"mask = distance_to_target <= 0\n",
"\n",
"plt.figure(figsize=(8, 4))\n",
"plt.subplot(121)\n",
"plt.plot(step, loss_values)\n",
"plt.xlabel(\"Step\")\n",
"plt.ylabel(\"Loss value\")\n",
"plt.subplot(122)\n",
"plt.plot(step, distance_to_target)\n",
"plt.plot(step[mask], distance_to_target[mask], \"bo\")\n",
"plt.xlabel(\"Step\")\n",
"plt.ylabel(\"Distance to target\")\n",
"\n",
"plt.tight_layout()"
]
Expand Down Expand Up @@ -225,6 +235,14 @@
"\n",
"plt.tight_layout()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b0bbe84b-fb49-4fad-8e11-020434312e3f",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit 11338ec

Please sign in to comment.