From e29c343e65933ad2d397914d9881797bd03fa46a Mon Sep 17 00:00:00 2001 From: myron Date: Wed, 5 Apr 2023 17:57:11 -0700 Subject: [PATCH 01/10] semantic updates for Auto3dseg Signed-off-by: myron --- .../auto3dseg_autorunner_ref_api.ipynb | 17 +++++++++-------- auto3dseg/notebooks/auto_runner.ipynb | 6 +++--- auto3dseg/notebooks/hpo_nni.ipynb | 9 ++++++--- auto3dseg/notebooks/hpo_optuna.ipynb | 10 +++++++--- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb b/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb index a56790987d..fcf41aaa07 100644 --- a/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb +++ b/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb @@ -307,12 +307,13 @@ "metadata": {}, "outputs": [], "source": [ + "from monai.utils.enums import AlgoEnsembleKeys\n", "history = import_bundle_algo_history(work_dir, only_trained=False)\n", - "for task in history:\n", - " for _, algo in task.items():\n", - " algo.train(train_param) # can use default params by `algo.train()`\n", - " acc = algo.get_score()\n", - " algo_to_pickle(algo, template_path=algo.template_path, best_metrics=acc)" + "for algo_dict in history:\n", + " algo = algo_dict[AlgoEnsembleKeys.ID]\n", + " algo.train(train_param) # can use default params by `algo.train()`\n", + " acc = algo.get_score()\n", + " algo_to_pickle(algo, template_path=algo.template_path, best_metric=acc)" ] }, { @@ -355,7 +356,7 @@ ], "metadata": { "kernelspec": { - "display_name": "monai-0", + "display_name": "base", "language": "python", "name": "python3" }, @@ -369,11 +370,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.13 (default, Mar 28 2022, 06:59:08) [MSC v.1916 64 bit (AMD64)]" + "version": "3.9.16" }, "vscode": { "interpreter": { - "hash": "85754776c861f3ba5898fde994bfc400ed208cd401a6036e85fdc16c4f506eaf" + "hash": "adad466f3ae0207e0597f6bf999e86a6601b04f4db83734c81b06a9e73a01812" } } }, diff --git a/auto3dseg/notebooks/auto_runner.ipynb b/auto3dseg/notebooks/auto_runner.ipynb index 37bb2444b6..16e6ea2612 100644 --- a/auto3dseg/notebooks/auto_runner.ipynb +++ b/auto3dseg/notebooks/auto_runner.ipynb @@ -484,7 +484,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -498,11 +498,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.13" + "version": "3.9.16" }, "vscode": { "interpreter": { - "hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1" + "hash": "adad466f3ae0207e0597f6bf999e86a6601b04f4db83734c81b06a9e73a01812" } } }, diff --git a/auto3dseg/notebooks/hpo_nni.ipynb b/auto3dseg/notebooks/hpo_nni.ipynb index 449deab399..036a0d18ca 100644 --- a/auto3dseg/notebooks/hpo_nni.ipynb +++ b/auto3dseg/notebooks/hpo_nni.ipynb @@ -223,8 +223,9 @@ " history = import_bundle_algo_history(work_dir, only_trained=False)\n", "\n", "print(\"algorithms imported from the history:\")\n", + "from monai.utils.enums import AlgoEnsembleKeys\n", "for i, algo_dict in enumerate(history):\n", - " print(f\"{i}: \", list(algo_dict.keys())[0])" + " print(f\"{i}: \", algo_dict[AlgoEnsembleKeys.ID])" ] }, { @@ -250,10 +251,12 @@ } ], "source": [ + "from monai.utils.enums import AlgoEnsembleKeys\n", + "\n", "selected_algorithm_index = 0\n", "algo_dict = history[selected_algorithm_index]\n", - "algo_name = list(algo_dict.keys())[0]\n", - "algo = algo_dict[algo_name]\n", + "algo_name = algo_dict[AlgoEnsembleKeys.ID]\n", + "algo = algo_dict[AlgoEnsembleKeys.ALGO]\n", "print(\"User selected algorithm: \")\n", "print(algo_name)" ] diff --git a/auto3dseg/notebooks/hpo_optuna.ipynb b/auto3dseg/notebooks/hpo_optuna.ipynb index 47cd562309..9599d73a6c 100644 --- a/auto3dseg/notebooks/hpo_optuna.ipynb +++ b/auto3dseg/notebooks/hpo_optuna.ipynb @@ -209,9 +209,11 @@ "except Exception:\n", " history = import_bundle_algo_history(work_dir, only_trained=False)\n", "\n", + "from monai.utils.enums import AlgoEnsembleKeys\n", + "\n", "print(\"algorithms imported from the history:\")\n", "for i, algo_dict in enumerate(history):\n", - " print(f\"{i}: \", list(algo_dict.keys())[0])" + " print(f\"{i}: \", algo_dict[AlgoEnsembleKeys.ID])" ] }, { @@ -228,10 +230,12 @@ "metadata": {}, "outputs": [], "source": [ + "from monai.utils.enums import AlgoEnsembleKeys\n", + "\n", "selected_algorithm_index = 0\n", "algo_dict = history[selected_algorithm_index]\n", - "algo_name = list(algo_dict.keys())[0]\n", - "algo = algo_dict[algo_name]\n", + "algo_name = algo_dict[AlgoEnsembleKeys.ID]\n", + "algo = algo_dict[AlgoEnsembleKeys.ALGO]\n", "print(\"User selected algorithm: \")\n", "print(algo_name)" ] From a0e1d212a4183625543b67fd4f191a00d515fca8 Mon Sep 17 00:00:00 2001 From: myron Date: Wed, 5 Apr 2023 18:00:18 -0700 Subject: [PATCH 02/10] small Signed-off-by: myron --- auto3dseg/notebooks/auto_runner.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/auto3dseg/notebooks/auto_runner.ipynb b/auto3dseg/notebooks/auto_runner.ipynb index 16e6ea2612..37bb2444b6 100644 --- a/auto3dseg/notebooks/auto_runner.ipynb +++ b/auto3dseg/notebooks/auto_runner.ipynb @@ -484,7 +484,7 @@ ], "metadata": { "kernelspec": { - "display_name": "base", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -498,11 +498,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.8.13" }, "vscode": { "interpreter": { - "hash": "adad466f3ae0207e0597f6bf999e86a6601b04f4db83734c81b06a9e73a01812" + "hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1" } } }, From e1041a71228ff45983697e97ff4dea0161e2bedf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 6 Apr 2023 01:01:32 +0000 Subject: [PATCH 03/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb | 1 + auto3dseg/notebooks/hpo_nni.ipynb | 1 + 2 files changed, 2 insertions(+) diff --git a/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb b/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb index fcf41aaa07..8522bda3ca 100644 --- a/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb +++ b/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb @@ -308,6 +308,7 @@ "outputs": [], "source": [ "from monai.utils.enums import AlgoEnsembleKeys\n", + "\n", "history = import_bundle_algo_history(work_dir, only_trained=False)\n", "for algo_dict in history:\n", " algo = algo_dict[AlgoEnsembleKeys.ID]\n", diff --git a/auto3dseg/notebooks/hpo_nni.ipynb b/auto3dseg/notebooks/hpo_nni.ipynb index 036a0d18ca..8ed20dc7fa 100644 --- a/auto3dseg/notebooks/hpo_nni.ipynb +++ b/auto3dseg/notebooks/hpo_nni.ipynb @@ -224,6 +224,7 @@ "\n", "print(\"algorithms imported from the history:\")\n", "from monai.utils.enums import AlgoEnsembleKeys\n", + "\n", "for i, algo_dict in enumerate(history):\n", " print(f\"{i}: \", algo_dict[AlgoEnsembleKeys.ID])" ] From d815cad1e3ffac401a44f853d9825eefca1bf40a Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Thu, 13 Apr 2023 13:38:00 +0100 Subject: [PATCH 04/10] fixes Signed-off-by: Wenqi Li --- auto3dseg/notebooks/hpo_nni.ipynb | 5 +---- auto3dseg/notebooks/hpo_optuna.ipynb | 6 +----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/auto3dseg/notebooks/hpo_nni.ipynb b/auto3dseg/notebooks/hpo_nni.ipynb index 8ed20dc7fa..07d9270231 100644 --- a/auto3dseg/notebooks/hpo_nni.ipynb +++ b/auto3dseg/notebooks/hpo_nni.ipynb @@ -76,12 +76,12 @@ "from monai.apps.auto3dseg.utils import export_bundle_algo_history, import_bundle_algo_history\n", "from monai.bundle.config_parser import ConfigParser\n", "from monai.config import print_config\n", + "from monai.utils.enums import AlgoEnsembleKeys\n", "\n", "print_config()" ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -223,7 +223,6 @@ " history = import_bundle_algo_history(work_dir, only_trained=False)\n", "\n", "print(\"algorithms imported from the history:\")\n", - "from monai.utils.enums import AlgoEnsembleKeys\n", "\n", "for i, algo_dict in enumerate(history):\n", " print(f\"{i}: \", algo_dict[AlgoEnsembleKeys.ID])" @@ -252,8 +251,6 @@ } ], "source": [ - "from monai.utils.enums import AlgoEnsembleKeys\n", - "\n", "selected_algorithm_index = 0\n", "algo_dict = history[selected_algorithm_index]\n", "algo_name = algo_dict[AlgoEnsembleKeys.ID]\n", diff --git a/auto3dseg/notebooks/hpo_optuna.ipynb b/auto3dseg/notebooks/hpo_optuna.ipynb index 9599d73a6c..1c99647faa 100644 --- a/auto3dseg/notebooks/hpo_optuna.ipynb +++ b/auto3dseg/notebooks/hpo_optuna.ipynb @@ -69,6 +69,7 @@ "from monai.apps.auto3dseg.utils import export_bundle_algo_history, import_bundle_algo_history\n", "from monai.bundle.config_parser import ConfigParser\n", "from monai.config import print_config\n", + "from monai.utils.enums import AlgoEnsembleKeys\n", "\n", "print_config()" ] @@ -209,8 +210,6 @@ "except Exception:\n", " history = import_bundle_algo_history(work_dir, only_trained=False)\n", "\n", - "from monai.utils.enums import AlgoEnsembleKeys\n", - "\n", "print(\"algorithms imported from the history:\")\n", "for i, algo_dict in enumerate(history):\n", " print(f\"{i}: \", algo_dict[AlgoEnsembleKeys.ID])" @@ -230,8 +229,6 @@ "metadata": {}, "outputs": [], "source": [ - "from monai.utils.enums import AlgoEnsembleKeys\n", - "\n", "selected_algorithm_index = 0\n", "algo_dict = history[selected_algorithm_index]\n", "algo_name = algo_dict[AlgoEnsembleKeys.ID]\n", @@ -241,7 +238,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ From 52288605453f97572a4a6ca9568771bae655d46d Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Thu, 13 Apr 2023 13:53:12 +0100 Subject: [PATCH 05/10] fixes Signed-off-by: Wenqi Li --- auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb b/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb index 8522bda3ca..c7b861723b 100644 --- a/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb +++ b/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb @@ -71,7 +71,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -224,7 +223,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -246,7 +244,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -307,8 +304,6 @@ "metadata": {}, "outputs": [], "source": [ - "from monai.utils.enums import AlgoEnsembleKeys\n", - "\n", "history = import_bundle_algo_history(work_dir, only_trained=False)\n", "for algo_dict in history:\n", " algo = algo_dict[AlgoEnsembleKeys.ID]\n", @@ -357,7 +352,7 @@ ], "metadata": { "kernelspec": { - "display_name": "base", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -371,7 +366,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.8.13" }, "vscode": { "interpreter": { From ad85fecc14b84b04a47e5a00864d1bd8e69000d1 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Thu, 13 Apr 2023 13:55:35 +0100 Subject: [PATCH 06/10] update Signed-off-by: Wenqi Li --- auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb | 1 + 1 file changed, 1 insertion(+) diff --git a/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb b/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb index c7b861723b..cd8e652437 100644 --- a/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb +++ b/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb @@ -66,6 +66,7 @@ "from monai.auto3dseg import algo_to_pickle\n", "from monai.bundle.config_parser import ConfigParser\n", "from monai.config import print_config\n", + "from monai.utils.enums import AlgoEnsembleKeys\n", "\n", "print_config()" ] From 9e38267fe7852fb86bd306030f618f8a6b1e7b3e Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Thu, 13 Apr 2023 14:03:33 +0100 Subject: [PATCH 07/10] update Signed-off-by: Wenqi Li --- auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb b/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb index cd8e652437..cc9fbb8471 100644 --- a/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb +++ b/auto3dseg/notebooks/auto3dseg_autorunner_ref_api.ipynb @@ -66,7 +66,7 @@ "from monai.auto3dseg import algo_to_pickle\n", "from monai.bundle.config_parser import ConfigParser\n", "from monai.config import print_config\n", - "from monai.utils.enums import AlgoEnsembleKeys\n", + "from monai.utils.enums import AlgoKeys\n", "\n", "print_config()" ] @@ -307,7 +307,7 @@ "source": [ "history = import_bundle_algo_history(work_dir, only_trained=False)\n", "for algo_dict in history:\n", - " algo = algo_dict[AlgoEnsembleKeys.ID]\n", + " algo = algo_dict[AlgoKeys.ALGO]\n", " algo.train(train_param) # can use default params by `algo.train()`\n", " acc = algo.get_score()\n", " algo_to_pickle(algo, template_path=algo.template_path, best_metric=acc)" From 8a21305687463d1ececc4f9a30cd5736daeea876 Mon Sep 17 00:00:00 2001 From: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com> Date: Thu, 13 Apr 2023 13:27:48 +0000 Subject: [PATCH 08/10] update markdonw Signed-off-by: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com> --- auto3dseg/docs/ensemble.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto3dseg/docs/ensemble.md b/auto3dseg/docs/ensemble.md index e38eeb4ad5..bb6e7fb2a8 100644 --- a/auto3dseg/docs/ensemble.md +++ b/auto3dseg/docs/ensemble.md @@ -15,7 +15,7 @@ from monai.apps.auto3dseg import ( AlgoEnsembleBuilder, import_bundle_algo_history, ) -from monai.utils.enums import AlgoEnsembleKeys +from monai.utils.enums import AlgoKeys # Assuming you have already trained the models @@ -33,7 +33,7 @@ ensemble = builder.get_ensemble() pred = ensemble() print("ensemble picked the following best {0:d}:".format(n_best)) for algo in ensemble.get_algo_ensemble(): - print(algo[AlgoEnsembleKeys.ID]) + print(algo[AlgoKeys.ID]) ``` ### Customization From 6fef68dfefc01825a69d0b6c6daf7b19366ab5e7 Mon Sep 17 00:00:00 2001 From: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com> Date: Thu, 13 Apr 2023 13:32:56 +0000 Subject: [PATCH 09/10] update notebooks Signed-off-by: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com> --- auto3dseg/notebooks/ensemble_byoc.ipynb | 20 ++++++++++---------- auto3dseg/notebooks/hpo_nni.ipynb | 8 ++++---- auto3dseg/notebooks/hpo_optuna.ipynb | 8 ++++---- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/auto3dseg/notebooks/ensemble_byoc.ipynb b/auto3dseg/notebooks/ensemble_byoc.ipynb index 8e1b62308c..6f5d432c78 100644 --- a/auto3dseg/notebooks/ensemble_byoc.ipynb +++ b/auto3dseg/notebooks/ensemble_byoc.ipynb @@ -31,7 +31,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -70,7 +70,7 @@ "from monai.bundle.config_parser import ConfigParser\n", "from monai.config import print_config\n", "from monai.data import create_test_image_3d\n", - "from monai.utils.enums import AlgoEnsembleKeys\n", + "from monai.utils.enums import AlgoKeys\n", "\n", "print_config()" ] @@ -91,7 +91,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -130,7 +130,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -165,7 +165,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -239,9 +239,9 @@ " \"num_warmup_epochs\": 1,\n", "}\n", "\n", - "for h in history:\n", - " for _, algo in h.items():\n", - " algo.train(train_param)" + "for algo_dict in history:\n", + " algo = algo_dict[AlgoKeys.ALGO]\n", + " algo.train(train_param)" ] }, { @@ -266,7 +266,7 @@ "\n", "print(\"The ensemble randomly picks the following models:\")\n", "for algo in ensemble.get_algo_ensemble():\n", - " print(algo[AlgoEnsembleKeys.ID])" + " print(algo[AlgoKeys.ID])" ] } ], @@ -286,7 +286,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.13" + "version": "3.8.10" }, "vscode": { "interpreter": { diff --git a/auto3dseg/notebooks/hpo_nni.ipynb b/auto3dseg/notebooks/hpo_nni.ipynb index 07d9270231..45b5d1ac46 100644 --- a/auto3dseg/notebooks/hpo_nni.ipynb +++ b/auto3dseg/notebooks/hpo_nni.ipynb @@ -76,7 +76,7 @@ "from monai.apps.auto3dseg.utils import export_bundle_algo_history, import_bundle_algo_history\n", "from monai.bundle.config_parser import ConfigParser\n", "from monai.config import print_config\n", - "from monai.utils.enums import AlgoEnsembleKeys\n", + "from monai.utils.enums import AlgoKeys\n", "\n", "print_config()" ] @@ -225,7 +225,7 @@ "print(\"algorithms imported from the history:\")\n", "\n", "for i, algo_dict in enumerate(history):\n", - " print(f\"{i}: \", algo_dict[AlgoEnsembleKeys.ID])" + " print(f\"{i}: \", algo_dict[AlgoKeys.ID])" ] }, { @@ -253,8 +253,8 @@ "source": [ "selected_algorithm_index = 0\n", "algo_dict = history[selected_algorithm_index]\n", - "algo_name = algo_dict[AlgoEnsembleKeys.ID]\n", - "algo = algo_dict[AlgoEnsembleKeys.ALGO]\n", + "algo_name = algo_dict[AlgoKeys.ID]\n", + "algo = algo_dict[AlgoKeys.ALGO]\n", "print(\"User selected algorithm: \")\n", "print(algo_name)" ] diff --git a/auto3dseg/notebooks/hpo_optuna.ipynb b/auto3dseg/notebooks/hpo_optuna.ipynb index 1c99647faa..212d34978a 100644 --- a/auto3dseg/notebooks/hpo_optuna.ipynb +++ b/auto3dseg/notebooks/hpo_optuna.ipynb @@ -69,7 +69,7 @@ "from monai.apps.auto3dseg.utils import export_bundle_algo_history, import_bundle_algo_history\n", "from monai.bundle.config_parser import ConfigParser\n", "from monai.config import print_config\n", - "from monai.utils.enums import AlgoEnsembleKeys\n", + "from monai.utils.enums import AlgoKeys\n", "\n", "print_config()" ] @@ -212,7 +212,7 @@ "\n", "print(\"algorithms imported from the history:\")\n", "for i, algo_dict in enumerate(history):\n", - " print(f\"{i}: \", algo_dict[AlgoEnsembleKeys.ID])" + " print(f\"{i}: \", algo_dict[AlgoKeys.ID])" ] }, { @@ -231,8 +231,8 @@ "source": [ "selected_algorithm_index = 0\n", "algo_dict = history[selected_algorithm_index]\n", - "algo_name = algo_dict[AlgoEnsembleKeys.ID]\n", - "algo = algo_dict[AlgoEnsembleKeys.ALGO]\n", + "algo_name = algo_dict[AlgoKeys.ID]\n", + "algo = algo_dict[AlgoKeys.ALGO]\n", "print(\"User selected algorithm: \")\n", "print(algo_name)" ] From 77fefef991c4b14a82e029a5327ffdd158d90046 Mon Sep 17 00:00:00 2001 From: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com> Date: Thu, 13 Apr 2023 16:13:29 +0000 Subject: [PATCH 10/10] fix test taking too long Signed-off-by: Mingxin Zheng <18563433+mingxin-zheng@users.noreply.github.com> --- auto3dseg/notebooks/hpo_nni.ipynb | 35 ++++++---------------------- auto3dseg/notebooks/hpo_optuna.ipynb | 10 ++++---- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/auto3dseg/notebooks/hpo_nni.ipynb b/auto3dseg/notebooks/hpo_nni.ipynb index 45b5d1ac46..7a32863f18 100644 --- a/auto3dseg/notebooks/hpo_nni.ipynb +++ b/auto3dseg/notebooks/hpo_nni.ipynb @@ -202,19 +202,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "algorithms imported from the history:\n", - "0: segresnet2d_0\n", - "1: dints_0\n", - "2: swinunetr_0\n", - "3: segresnet_0\n" - ] - } - ], + "outputs": [], "source": [ "try:\n", " history = bundle_generator.get_history()\n", @@ -240,23 +228,14 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "User selected algorithm: \n", - "segresnet2d_0\n" - ] - } - ], + "outputs": [], "source": [ - "selected_algorithm_index = 0\n", - "algo_dict = history[selected_algorithm_index]\n", + "for algo_dict in history:\n", + " if algo_dict[AlgoKeys.ID].split(\"_\")[0] == \"segresnet\":\n", + " break\n", "algo_name = algo_dict[AlgoKeys.ID]\n", "algo = algo_dict[AlgoKeys.ALGO]\n", - "print(\"User selected algorithm: \")\n", - "print(algo_name)" + "print(f\"{algo_name} is selected. \")" ] }, { @@ -383,7 +362,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.13" + "version": "3.8.10" }, "vscode": { "interpreter": { diff --git a/auto3dseg/notebooks/hpo_optuna.ipynb b/auto3dseg/notebooks/hpo_optuna.ipynb index 212d34978a..8b145e0fdb 100644 --- a/auto3dseg/notebooks/hpo_optuna.ipynb +++ b/auto3dseg/notebooks/hpo_optuna.ipynb @@ -229,12 +229,12 @@ "metadata": {}, "outputs": [], "source": [ - "selected_algorithm_index = 0\n", - "algo_dict = history[selected_algorithm_index]\n", + "for algo_dict in history:\n", + " if algo_dict[AlgoKeys.ID].split(\"_\")[0] == \"segresnet\":\n", + " break\n", "algo_name = algo_dict[AlgoKeys.ID]\n", "algo = algo_dict[AlgoKeys.ALGO]\n", - "print(\"User selected algorithm: \")\n", - "print(algo_name)" + "print(f\"{algo_name} is selected. \")" ] }, { @@ -333,7 +333,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.13" + "version": "3.8.10" }, "vscode": { "interpreter": {