Skip to content

Commit 03e5172

Browse files
committed
Rerun inversion in notebook 10
Show that we can reuse the conditions, and that the inversion will clean attributes.
1 parent 68c2b1f commit 03e5172

File tree

1 file changed

+149
-61
lines changed

1 file changed

+149
-61
lines changed

notebooks/10_multiple-conditions.ipynb

Lines changed: 149 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
"id": "eb4145ad-9d6a-411f-aa2e-7ab211a1f737",
1515
"metadata": {
1616
"execution": {
17-
"iopub.execute_input": "2025-08-18T17:23:53.940759Z",
18-
"iopub.status.busy": "2025-08-18T17:23:53.940456Z",
19-
"iopub.status.idle": "2025-08-18T17:23:54.225520Z",
20-
"shell.execute_reply": "2025-08-18T17:23:54.224966Z",
21-
"shell.execute_reply.started": "2025-08-18T17:23:53.940732Z"
17+
"iopub.execute_input": "2025-08-19T21:41:04.669515Z",
18+
"iopub.status.busy": "2025-08-19T21:41:04.669203Z",
19+
"iopub.status.idle": "2025-08-19T21:41:04.945352Z",
20+
"shell.execute_reply": "2025-08-19T21:41:04.944681Z",
21+
"shell.execute_reply.started": "2025-08-19T21:41:04.669484Z"
2222
}
2323
},
2424
"outputs": [],
@@ -53,11 +53,11 @@
5353
"id": "22f226e2-d715-49e8-b357-38e71d78bcdc",
5454
"metadata": {
5555
"execution": {
56-
"iopub.execute_input": "2025-08-18T17:23:54.226106Z",
57-
"iopub.status.busy": "2025-08-18T17:23:54.225896Z",
58-
"iopub.status.idle": "2025-08-18T17:23:54.232695Z",
59-
"shell.execute_reply": "2025-08-18T17:23:54.232002Z",
60-
"shell.execute_reply.started": "2025-08-18T17:23:54.226089Z"
56+
"iopub.execute_input": "2025-08-19T21:41:04.946145Z",
57+
"iopub.status.busy": "2025-08-19T21:41:04.945883Z",
58+
"iopub.status.idle": "2025-08-19T21:41:04.953331Z",
59+
"shell.execute_reply": "2025-08-19T21:41:04.952578Z",
60+
"shell.execute_reply.started": "2025-08-19T21:41:04.946127Z"
6161
}
6262
},
6363
"outputs": [
@@ -86,11 +86,11 @@
8686
"id": "0e39a2d1-d26e-4ee2-8f9f-f3b33f1ac124",
8787
"metadata": {
8888
"execution": {
89-
"iopub.execute_input": "2025-08-18T17:23:54.233791Z",
90-
"iopub.status.busy": "2025-08-18T17:23:54.233422Z",
91-
"iopub.status.idle": "2025-08-18T17:23:54.240691Z",
92-
"shell.execute_reply": "2025-08-18T17:23:54.240025Z",
93-
"shell.execute_reply.started": "2025-08-18T17:23:54.233768Z"
89+
"iopub.execute_input": "2025-08-19T21:41:04.954572Z",
90+
"iopub.status.busy": "2025-08-19T21:41:04.954122Z",
91+
"iopub.status.idle": "2025-08-19T21:41:04.964967Z",
92+
"shell.execute_reply": "2025-08-19T21:41:04.964292Z",
93+
"shell.execute_reply.started": "2025-08-19T21:41:04.954540Z"
9494
}
9595
},
9696
"outputs": [],
@@ -107,11 +107,11 @@
107107
"id": "8f052ed5-3a2b-4f32-8b44-8a86ea278960",
108108
"metadata": {
109109
"execution": {
110-
"iopub.execute_input": "2025-08-18T17:23:54.241630Z",
111-
"iopub.status.busy": "2025-08-18T17:23:54.241343Z",
112-
"iopub.status.idle": "2025-08-18T17:23:54.251154Z",
113-
"shell.execute_reply": "2025-08-18T17:23:54.250541Z",
114-
"shell.execute_reply.started": "2025-08-18T17:23:54.241603Z"
110+
"iopub.execute_input": "2025-08-19T21:41:04.965645Z",
111+
"iopub.status.busy": "2025-08-19T21:41:04.965424Z",
112+
"iopub.status.idle": "2025-08-19T21:41:04.991306Z",
113+
"shell.execute_reply": "2025-08-19T21:41:04.990629Z",
114+
"shell.execute_reply.started": "2025-08-19T21:41:04.965627Z"
115115
}
116116
},
117117
"outputs": [
@@ -152,11 +152,11 @@
152152
"id": "ae80cc54-96f9-4a85-ad1f-9dce5dc38870",
153153
"metadata": {
154154
"execution": {
155-
"iopub.execute_input": "2025-08-18T17:23:54.251883Z",
156-
"iopub.status.busy": "2025-08-18T17:23:54.251701Z",
157-
"iopub.status.idle": "2025-08-18T17:23:54.257609Z",
158-
"shell.execute_reply": "2025-08-18T17:23:54.256978Z",
159-
"shell.execute_reply.started": "2025-08-18T17:23:54.251865Z"
155+
"iopub.execute_input": "2025-08-19T21:41:04.992415Z",
156+
"iopub.status.busy": "2025-08-19T21:41:04.992136Z",
157+
"iopub.status.idle": "2025-08-19T21:41:05.000885Z",
158+
"shell.execute_reply": "2025-08-19T21:41:05.000128Z",
159+
"shell.execute_reply.started": "2025-08-19T21:41:04.992385Z"
160160
}
161161
},
162162
"outputs": [],
@@ -172,11 +172,11 @@
172172
"id": "050b9c20-4b0a-49af-a900-1bb964588408",
173173
"metadata": {
174174
"execution": {
175-
"iopub.execute_input": "2025-08-18T17:23:54.259923Z",
176-
"iopub.status.busy": "2025-08-18T17:23:54.259634Z",
177-
"iopub.status.idle": "2025-08-18T17:23:54.264841Z",
178-
"shell.execute_reply": "2025-08-18T17:23:54.264096Z",
179-
"shell.execute_reply.started": "2025-08-18T17:23:54.259904Z"
175+
"iopub.execute_input": "2025-08-19T21:41:05.003627Z",
176+
"iopub.status.busy": "2025-08-19T21:41:05.003282Z",
177+
"iopub.status.idle": "2025-08-19T21:41:05.010318Z",
178+
"shell.execute_reply": "2025-08-19T21:41:05.009586Z",
179+
"shell.execute_reply.started": "2025-08-19T21:41:05.003595Z"
180180
}
181181
},
182182
"outputs": [],
@@ -190,11 +190,11 @@
190190
"id": "b6e3ea36-dc6b-4aa1-99b8-31721937d933",
191191
"metadata": {
192192
"execution": {
193-
"iopub.execute_input": "2025-08-18T17:23:54.265767Z",
194-
"iopub.status.busy": "2025-08-18T17:23:54.265518Z",
195-
"iopub.status.idle": "2025-08-18T17:23:54.275120Z",
196-
"shell.execute_reply": "2025-08-18T17:23:54.274507Z",
197-
"shell.execute_reply.started": "2025-08-18T17:23:54.265731Z"
193+
"iopub.execute_input": "2025-08-19T21:41:05.011406Z",
194+
"iopub.status.busy": "2025-08-19T21:41:05.011132Z",
195+
"iopub.status.idle": "2025-08-19T21:41:05.017701Z",
196+
"shell.execute_reply": "2025-08-19T21:41:05.016838Z",
197+
"shell.execute_reply.started": "2025-08-19T21:41:05.011376Z"
198198
}
199199
},
200200
"outputs": [],
@@ -226,11 +226,11 @@
226226
"id": "cf72d7ed-3565-466f-b13a-40a5d359eb9c",
227227
"metadata": {
228228
"execution": {
229-
"iopub.execute_input": "2025-08-18T17:23:54.275851Z",
230-
"iopub.status.busy": "2025-08-18T17:23:54.275668Z",
231-
"iopub.status.idle": "2025-08-18T17:23:54.281858Z",
232-
"shell.execute_reply": "2025-08-18T17:23:54.281247Z",
233-
"shell.execute_reply.started": "2025-08-18T17:23:54.275833Z"
229+
"iopub.execute_input": "2025-08-19T21:41:05.018713Z",
230+
"iopub.status.busy": "2025-08-19T21:41:05.018437Z",
231+
"iopub.status.idle": "2025-08-19T21:41:05.024856Z",
232+
"shell.execute_reply": "2025-08-19T21:41:05.024210Z",
233+
"shell.execute_reply.started": "2025-08-19T21:41:05.018684Z"
234234
}
235235
},
236236
"outputs": [],
@@ -251,18 +251,18 @@
251251
"id": "7a8ddaa6-42e3-44d4-8032-654f82b676c8",
252252
"metadata": {
253253
"execution": {
254-
"iopub.execute_input": "2025-08-18T17:23:54.282817Z",
255-
"iopub.status.busy": "2025-08-18T17:23:54.282546Z",
256-
"iopub.status.idle": "2025-08-18T17:23:59.514283Z",
257-
"shell.execute_reply": "2025-08-18T17:23:59.512108Z",
258-
"shell.execute_reply.started": "2025-08-18T17:23:54.282789Z"
254+
"iopub.execute_input": "2025-08-19T21:41:05.025806Z",
255+
"iopub.status.busy": "2025-08-19T21:41:05.025543Z",
256+
"iopub.status.idle": "2025-08-19T21:41:10.235671Z",
257+
"shell.execute_reply": "2025-08-19T21:41:10.234737Z",
258+
"shell.execute_reply.started": "2025-08-19T21:41:05.025777Z"
259259
}
260260
},
261261
"outputs": [
262262
{
263263
"data": {
264264
"application/vnd.jupyter.widget-view+json": {
265-
"model_id": "72e403beb97b438e812b2881ced13575",
265+
"model_id": "50a49723344b47d9a600a06150748a3a",
266266
"version_major": 2,
267267
"version_minor": 0
268268
},
@@ -301,11 +301,11 @@
301301
"id": "9c9040bc-fca0-4654-a843-765c6a4c1b4b",
302302
"metadata": {
303303
"execution": {
304-
"iopub.execute_input": "2025-08-18T17:23:59.516255Z",
305-
"iopub.status.busy": "2025-08-18T17:23:59.515820Z",
306-
"iopub.status.idle": "2025-08-18T17:23:59.524459Z",
307-
"shell.execute_reply": "2025-08-18T17:23:59.523147Z",
308-
"shell.execute_reply.started": "2025-08-18T17:23:59.516218Z"
304+
"iopub.execute_input": "2025-08-19T21:41:10.237217Z",
305+
"iopub.status.busy": "2025-08-19T21:41:10.236799Z",
306+
"iopub.status.idle": "2025-08-19T21:41:10.243189Z",
307+
"shell.execute_reply": "2025-08-19T21:41:10.242245Z",
308+
"shell.execute_reply.started": "2025-08-19T21:41:10.237179Z"
309309
}
310310
},
311311
"outputs": [
@@ -330,11 +330,11 @@
330330
"id": "2e7c0859-554d-47bb-8e3f-20f261bb67e1",
331331
"metadata": {
332332
"execution": {
333-
"iopub.execute_input": "2025-08-18T17:23:59.526014Z",
334-
"iopub.status.busy": "2025-08-18T17:23:59.525588Z",
335-
"iopub.status.idle": "2025-08-18T17:23:59.541181Z",
336-
"shell.execute_reply": "2025-08-18T17:23:59.540314Z",
337-
"shell.execute_reply.started": "2025-08-18T17:23:59.525959Z"
333+
"iopub.execute_input": "2025-08-19T21:41:10.245004Z",
334+
"iopub.status.busy": "2025-08-19T21:41:10.244227Z",
335+
"iopub.status.idle": "2025-08-19T21:41:10.257874Z",
336+
"shell.execute_reply": "2025-08-19T21:41:10.257138Z",
337+
"shell.execute_reply.started": "2025-08-19T21:41:10.244966Z"
338338
}
339339
},
340340
"outputs": [
@@ -359,11 +359,11 @@
359359
"id": "53880cc0-fc58-4965-8e9f-1201fe302b28",
360360
"metadata": {
361361
"execution": {
362-
"iopub.execute_input": "2025-08-18T17:23:59.542247Z",
363-
"iopub.status.busy": "2025-08-18T17:23:59.541985Z",
364-
"iopub.status.idle": "2025-08-18T17:23:59.551141Z",
365-
"shell.execute_reply": "2025-08-18T17:23:59.550369Z",
366-
"shell.execute_reply.started": "2025-08-18T17:23:59.542217Z"
362+
"iopub.execute_input": "2025-08-19T21:41:10.258705Z",
363+
"iopub.status.busy": "2025-08-19T21:41:10.258471Z",
364+
"iopub.status.idle": "2025-08-19T21:41:10.268130Z",
365+
"shell.execute_reply": "2025-08-19T21:41:10.267481Z",
366+
"shell.execute_reply.started": "2025-08-19T21:41:10.258681Z"
367367
}
368368
},
369369
"outputs": [
@@ -381,6 +381,94 @@
381381
"source": [
382382
"phi_changed(inverted_model)"
383383
]
384+
},
385+
{
386+
"cell_type": "markdown",
387+
"id": "55937146-ef20-4d80-a03b-60d5cdefc4b0",
388+
"metadata": {},
389+
"source": [
390+
"## Reuse conditions\n",
391+
"\n",
392+
"If we reuse the conditions, the new inversion should initialize the stopping criteria on the zeroth inversion, starting from fresh."
393+
]
394+
},
395+
{
396+
"cell_type": "code",
397+
"execution_count": 13,
398+
"id": "0cb8a52b-19f7-45b7-a4eb-3ed6df4a71b4",
399+
"metadata": {
400+
"execution": {
401+
"iopub.execute_input": "2025-08-19T21:41:10.269398Z",
402+
"iopub.status.busy": "2025-08-19T21:41:10.269054Z",
403+
"iopub.status.idle": "2025-08-19T21:41:10.276628Z",
404+
"shell.execute_reply": "2025-08-19T21:41:10.275840Z",
405+
"shell.execute_reply.started": "2025-08-19T21:41:10.269362Z"
406+
}
407+
},
408+
"outputs": [],
409+
"source": [
410+
"# Reset starting beta in the regularization\n",
411+
"regularization.multiplier = 1e4\n",
412+
"\n",
413+
"inversion = Inversion(\n",
414+
" phi,\n",
415+
" initial_model,\n",
416+
" minimizer,\n",
417+
" directives=[beta_cooler],\n",
418+
" stopping_criteria=stopping_criteria,\n",
419+
" cache_models=True,\n",
420+
")"
421+
]
422+
},
423+
{
424+
"cell_type": "code",
425+
"execution_count": 14,
426+
"id": "14a40cb0-d5f9-44f8-ba1e-cd1f26908737",
427+
"metadata": {
428+
"execution": {
429+
"iopub.execute_input": "2025-08-19T21:41:10.277551Z",
430+
"iopub.status.busy": "2025-08-19T21:41:10.277313Z",
431+
"iopub.status.idle": "2025-08-19T21:41:15.427083Z",
432+
"shell.execute_reply": "2025-08-19T21:41:15.426242Z",
433+
"shell.execute_reply.started": "2025-08-19T21:41:10.277527Z"
434+
}
435+
},
436+
"outputs": [
437+
{
438+
"data": {
439+
"application/vnd.jupyter.widget-view+json": {
440+
"model_id": "fd8dad1c834b4944b2a08b4be76cba4d",
441+
"version_major": 2,
442+
"version_minor": 0
443+
},
444+
"text/plain": [
445+
"Output()"
446+
]
447+
},
448+
"metadata": {},
449+
"output_type": "display_data"
450+
},
451+
{
452+
"name": "stderr",
453+
"output_type": "stream",
454+
"text": [
455+
"INFO: 🎉 Inversion successfully finished due to stopping critiera.\n"
456+
]
457+
},
458+
{
459+
"data": {
460+
"text/html": [
461+
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"></pre>\n"
462+
],
463+
"text/plain": []
464+
},
465+
"metadata": {},
466+
"output_type": "display_data"
467+
}
468+
],
469+
"source": [
470+
"inverted_model = inversion.run()"
471+
]
384472
}
385473
],
386474
"metadata": {

0 commit comments

Comments
 (0)