Skip to content

Commit

Permalink
note units of max size
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunsavel committed Nov 8, 2023
1 parent 8020d64 commit 3c7a263
Showing 1 changed file with 96 additions and 20 deletions.
116 changes: 96 additions & 20 deletions docs/pages/optimizing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
{
"cell_type": "markdown",
"id": "c72aa35f-e048-4b21-8dbb-543f2784a7c1",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"# Optimizing fits"
]
},
{
"cell_type": "markdown",
"id": "ce5e8765-93d8-469d-b489-ed33402fd4c9",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"At this point, we know how to fit functions to opacity dependence as a function of temperature, pressure, and wavelength. The question remains: Is our fit as good as it can be?\n",
"\n",
Expand All @@ -25,7 +33,11 @@
{
"cell_type": "markdown",
"id": "a0eb8ec2-c1e6-431d-a51e-d3de9c363f2c",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## Setting up the fit"
]
Expand All @@ -34,7 +46,11 @@
"cell_type": "code",
"execution_count": 1,
"id": "465e0289-4f8f-4785-9227-1291fbdd70ca",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import numpy as np\n",
Expand All @@ -58,7 +74,11 @@
"cell_type": "code",
"execution_count": 2,
"id": "9d382ad1-9356-41ad-95ec-175be6835eff",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stderr",
Expand Down Expand Up @@ -88,7 +108,11 @@
"cell_type": "code",
"execution_count": 3,
"id": "d1d67aca-ae6f-4597-8181-c989d738620c",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -124,7 +148,11 @@
{
"cell_type": "markdown",
"id": "aa5a4c0f-bcaf-4bae-8529-12ddb3ed2ac8",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"Things look pretty good — let's check to be sure."
]
Expand All @@ -133,7 +161,11 @@
"cell_type": "code",
"execution_count": 4,
"id": "287fa918-89a3-4e35-9839-edcee1167d8d",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -184,7 +216,11 @@
{
"cell_type": "markdown",
"id": "ff68ce2e-2524-493a-aa9b-55be0531a0d8",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## Optimization"
]
Expand All @@ -193,7 +229,11 @@
"cell_type": "code",
"execution_count": 5,
"id": "923edfe8-6c3f-4612-9025-9fbfb9ade1a8",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"optimizer = Optimizer(fitter)"
Expand All @@ -202,7 +242,11 @@
{
"cell_type": "markdown",
"id": "b3dadac9-7d03-4530-84e6-e9ac09fbfb44",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"Next, we need to restrict how many hyperparameters the `Optimizer` tests. \n",
"\n",
Expand All @@ -213,16 +257,24 @@
"cell_type": "code",
"execution_count": 6,
"id": "e193f1ca-4488-4526-95bd-9cb4c72d35d6",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"max_size = 1.6"
"max_size = 1.6 # in KB"
]
},
{
"cell_type": "markdown",
"id": "2be5ac80-23d4-434c-a850-8116f724f703",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"In addition to this parameter, we need to set the `max_evaluations` parameter. This parameter sets how many models the `Optimizer` tests, essentially setting how long the optimization takes. For the purposes of this tutorial, we'll set a relatively low number. Note that this is an upper bound — setting `max_evaluations = 8`, for instance, will only run 2 model evaluations."
]
Expand All @@ -231,7 +283,11 @@
"cell_type": "code",
"execution_count": 7,
"id": "55ceac04-e41e-489f-8e2d-75862552eb39",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"max_evaluations = 16"
Expand All @@ -240,7 +296,11 @@
{
"cell_type": "markdown",
"id": "a11cdfa2-db6f-4eff-8967-fd718dd7d5fa",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"Now, it's time to run the optimizer!"
]
Expand All @@ -249,7 +309,11 @@
"cell_type": "code",
"execution_count": 8,
"id": "9850ba7d-1ad9-4db4-a53c-004af1f3995d",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -291,7 +355,11 @@
{
"cell_type": "markdown",
"id": "a0f11df9-2c38-43d7-aad1-f2966d21746e",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"This took a couple of minutes on a laptop. Let's look at those best-fit parameters."
]
Expand All @@ -300,7 +368,11 @@
"cell_type": "code",
"execution_count": 9,
"id": "ff63a90b-a667-4779-838c-0dcaa918c698",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
Expand All @@ -320,7 +392,11 @@
{
"cell_type": "markdown",
"id": "cb6f7c1e-fa37-4e7e-84c5-1dffcb7b9416",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"Note that if you'd like, you can set custom ranges for each of the neural net parameters."
]
Expand Down

0 comments on commit 3c7a263

Please sign in to comment.