|
8413 | 8413 | "S_loaded_2.run()" |
8414 | 8414 | ] |
8415 | 8415 | }, |
| 8416 | + { |
| 8417 | + "cell_type": "markdown", |
| 8418 | + "metadata": {}, |
| 8419 | + "source": [ |
| 8420 | + "## print_exp_table()" |
| 8421 | + ] |
| 8422 | + }, |
| 8423 | + { |
| 8424 | + "cell_type": "code", |
| 8425 | + "execution_count": 3, |
| 8426 | + "metadata": {}, |
| 8427 | + "outputs": [ |
| 8428 | + { |
| 8429 | + "name": "stderr", |
| 8430 | + "output_type": "stream", |
| 8431 | + "text": [ |
| 8432 | + "Seed set to 123\n" |
| 8433 | + ] |
| 8434 | + }, |
| 8435 | + { |
| 8436 | + "name": "stdout", |
| 8437 | + "output_type": "stream", |
| 8438 | + "text": [ |
| 8439 | + "module_name: light\n", |
| 8440 | + "submodule_name: regression\n", |
| 8441 | + "model_name: NNLinearRegressor\n", |
| 8442 | + "| name | type | default | lower | upper | transform |\n", |
| 8443 | + "|----------------|--------|-----------|---------|---------|-----------------------|\n", |
| 8444 | + "| l1 | int | 3 | 1 | 2 | transform_power_2_int |\n", |
| 8445 | + "| epochs | int | 4 | 2 | 2 | transform_power_2_int |\n", |
| 8446 | + "| batch_size | int | 4 | 4 | 11 | transform_power_2_int |\n", |
| 8447 | + "| act_fn | factor | ReLU | 0 | 5 | None |\n", |
| 8448 | + "| optimizer | factor | SGD | 0 | 2 | None |\n", |
| 8449 | + "| dropout_prob | float | 0.01 | 0 | 0.025 | None |\n", |
| 8450 | + "| lr_mult | float | 1.0 | 0.1 | 10 | None |\n", |
| 8451 | + "| patience | int | 2 | 1 | 2 | transform_power_2_int |\n", |
| 8452 | + "| batch_norm | factor | 0 | 0 | 1 | None |\n", |
| 8453 | + "| initialization | factor | Default | 0 | 4 | None |\n" |
| 8454 | + ] |
| 8455 | + } |
| 8456 | + ], |
| 8457 | + "source": [ |
| 8458 | + "from spotpython.data.diabetes import Diabetes\n", |
| 8459 | + "from spotpython.hyperdict.light_hyper_dict import LightHyperDict\n", |
| 8460 | + "from spotpython.fun.hyperlight import HyperLight\n", |
| 8461 | + "from spotpython.utils.init import fun_control_init\n", |
| 8462 | + "from spotpython.utils.eda import print_exp_table, print_res_table\n", |
| 8463 | + "from spotpython.hyperparameters.values import set_hyperparameter\n", |
| 8464 | + "\n", |
| 8465 | + "fun_control = fun_control_init(\n", |
| 8466 | + " PREFIX=\"show_exp_table\",\n", |
| 8467 | + " fun_evals=5,\n", |
| 8468 | + " max_time=1,\n", |
| 8469 | + " data_set = Diabetes(),\n", |
| 8470 | + " core_model_name=\"light.regression.NNLinearRegressor\",\n", |
| 8471 | + " hyperdict=LightHyperDict,\n", |
| 8472 | + " _L_in=10,\n", |
| 8473 | + " _L_out=1)\n", |
| 8474 | + "\n", |
| 8475 | + "set_hyperparameter(fun_control, \"optimizer\", [ \"Adadelta\", \"Adam\", \"Adamax\"])\n", |
| 8476 | + "set_hyperparameter(fun_control, \"l1\", [1,2])\n", |
| 8477 | + "set_hyperparameter(fun_control, \"epochs\", [2,2])\n", |
| 8478 | + "set_hyperparameter(fun_control, \"batch_size\", [4,11])\n", |
| 8479 | + "set_hyperparameter(fun_control, \"dropout_prob\", [0.0, 0.025])\n", |
| 8480 | + "set_hyperparameter(fun_control, \"patience\", [1,2])\n", |
| 8481 | + "\n", |
| 8482 | + "fun = HyperLight().fun\n", |
| 8483 | + "\n", |
| 8484 | + "print_exp_table(fun_control)" |
| 8485 | + ] |
| 8486 | + }, |
| 8487 | + { |
| 8488 | + "cell_type": "markdown", |
| 8489 | + "metadata": {}, |
| 8490 | + "source": [ |
| 8491 | + "## print_res_table()" |
| 8492 | + ] |
| 8493 | + }, |
| 8494 | + { |
| 8495 | + "cell_type": "code", |
| 8496 | + "execution_count": 1, |
| 8497 | + "metadata": {}, |
| 8498 | + "outputs": [ |
| 8499 | + { |
| 8500 | + "name": "stderr", |
| 8501 | + "output_type": "stream", |
| 8502 | + "text": [ |
| 8503 | + "Seed set to 123\n", |
| 8504 | + "Seed set to 123\n", |
| 8505 | + "/Users/bartz/miniforge3/envs/spot312/lib/python3.12/site-packages/lightning/pytorch/utilities/parsing.py:208: Attribute 'act_fn' is an instance of `nn.Module` and is already saved during checkpointing. It is recommended to ignore them using `self.save_hyperparameters(ignore=['act_fn'])`.\n", |
| 8506 | + "GPU available: True (mps), used: True\n", |
| 8507 | + "TPU available: False, using: 0 TPU cores\n", |
| 8508 | + "HPU available: False, using: 0 HPUs\n", |
| 8509 | + "\n", |
| 8510 | + " | Name | Type | Params | Mode | In sizes | Out sizes\n", |
| 8511 | + "----------------------------------------------------------------------\n", |
| 8512 | + "0 | layers | Sequential | 14.2 K | train | [512, 10] | [512, 1] \n", |
| 8513 | + "----------------------------------------------------------------------\n", |
| 8514 | + "14.2 K Trainable params\n", |
| 8515 | + "0 Non-trainable params\n", |
| 8516 | + "14.2 K Total params\n", |
| 8517 | + "0.057 Total estimated model params size (MB)\n", |
| 8518 | + "24 Modules in train mode\n", |
| 8519 | + "0 Modules in eval mode\n", |
| 8520 | + "/Users/bartz/miniforge3/envs/spot312/lib/python3.12/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:424: The 'val_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=23` in the `DataLoader` to improve performance.\n" |
| 8521 | + ] |
| 8522 | + }, |
| 8523 | + { |
| 8524 | + "name": "stdout", |
| 8525 | + "output_type": "stream", |
| 8526 | + "text": [ |
| 8527 | + "module_name: light\n", |
| 8528 | + "submodule_name: regression\n", |
| 8529 | + "model_name: NNLinearRegressor\n", |
| 8530 | + "Experiment saved to show_exp_table_exp.pkl\n" |
| 8531 | + ] |
| 8532 | + }, |
| 8533 | + { |
| 8534 | + "name": "stderr", |
| 8535 | + "output_type": "stream", |
| 8536 | + "text": [ |
| 8537 | + "/Users/bartz/miniforge3/envs/spot312/lib/python3.12/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:424: The 'train_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=23` in the `DataLoader` to improve performance.\n", |
| 8538 | + "/Users/bartz/miniforge3/envs/spot312/lib/python3.12/site-packages/lightning/pytorch/loops/fit_loop.py:298: The number of training batches (1) is smaller than the logging interval Trainer(log_every_n_steps=50). Set a lower value for log_every_n_steps if you want to see logs for the training epoch.\n", |
| 8539 | + "`Trainer.fit` stopped: `max_epochs=4` reached.\n", |
| 8540 | + "GPU available: True (mps), used: True\n", |
| 8541 | + "TPU available: False, using: 0 TPU cores\n", |
| 8542 | + "HPU available: False, using: 0 HPUs\n", |
| 8543 | + "\n", |
| 8544 | + " | Name | Type | Params | Mode | In sizes | Out sizes\n", |
| 8545 | + "-----------------------------------------------------------------------\n", |
| 8546 | + "0 | layers | Sequential | 4.0 K | train | [1024, 10] | [1024, 1]\n", |
| 8547 | + "-----------------------------------------------------------------------\n", |
| 8548 | + "4.0 K Trainable params\n", |
| 8549 | + "0 Non-trainable params\n", |
| 8550 | + "4.0 K Total params\n", |
| 8551 | + "0.016 Total estimated model params size (MB)\n", |
| 8552 | + "24 Modules in train mode\n", |
| 8553 | + "0 Modules in eval mode\n" |
| 8554 | + ] |
| 8555 | + }, |
| 8556 | + { |
| 8557 | + "name": "stdout", |
| 8558 | + "output_type": "stream", |
| 8559 | + "text": [ |
| 8560 | + "train_model result: {'val_loss': 24008.939453125, 'hp_metric': 24008.939453125}\n" |
| 8561 | + ] |
| 8562 | + }, |
| 8563 | + { |
| 8564 | + "name": "stderr", |
| 8565 | + "output_type": "stream", |
| 8566 | + "text": [ |
| 8567 | + "GPU available: True (mps), used: True\n", |
| 8568 | + "TPU available: False, using: 0 TPU cores\n", |
| 8569 | + "HPU available: False, using: 0 HPUs\n", |
| 8570 | + "\n", |
| 8571 | + " | Name | Type | Params | Mode | In sizes | Out sizes\n", |
| 8572 | + "---------------------------------------------------------------------\n", |
| 8573 | + "0 | layers | Sequential | 3.7 K | train | [32, 10] | [32, 1] \n", |
| 8574 | + "---------------------------------------------------------------------\n", |
| 8575 | + "3.7 K Trainable params\n", |
| 8576 | + "0 Non-trainable params\n", |
| 8577 | + "3.7 K Total params\n", |
| 8578 | + "0.015 Total estimated model params size (MB)\n", |
| 8579 | + "17 Modules in train mode\n", |
| 8580 | + "0 Modules in eval mode\n" |
| 8581 | + ] |
| 8582 | + }, |
| 8583 | + { |
| 8584 | + "name": "stdout", |
| 8585 | + "output_type": "stream", |
| 8586 | + "text": [ |
| 8587 | + "train_model result: {'val_loss': 24078.296875, 'hp_metric': 24078.296875}\n" |
| 8588 | + ] |
| 8589 | + }, |
| 8590 | + { |
| 8591 | + "name": "stderr", |
| 8592 | + "output_type": "stream", |
| 8593 | + "text": [ |
| 8594 | + "/Users/bartz/miniforge3/envs/spot312/lib/python3.12/site-packages/lightning/pytorch/loops/fit_loop.py:298: The number of training batches (5) is smaller than the logging interval Trainer(log_every_n_steps=50). Set a lower value for log_every_n_steps if you want to see logs for the training epoch.\n", |
| 8595 | + "`Trainer.fit` stopped: `max_epochs=4` reached.\n", |
| 8596 | + "/Users/bartz/miniforge3/envs/spot312/lib/python3.12/site-packages/lightning/pytorch/utilities/parsing.py:208: Attribute 'act_fn' is an instance of `nn.Module` and is already saved during checkpointing. It is recommended to ignore them using `self.save_hyperparameters(ignore=['act_fn'])`.\n", |
| 8597 | + "GPU available: True (mps), used: True\n", |
| 8598 | + "TPU available: False, using: 0 TPU cores\n", |
| 8599 | + "HPU available: False, using: 0 HPUs\n", |
| 8600 | + "\n", |
| 8601 | + " | Name | Type | Params | Mode | In sizes | Out sizes\n", |
| 8602 | + "---------------------------------------------------------------------\n", |
| 8603 | + "0 | layers | Sequential | 13.5 K | train | [32, 10] | [32, 1] \n", |
| 8604 | + "---------------------------------------------------------------------\n", |
| 8605 | + "13.5 K Trainable params\n", |
| 8606 | + "0 Non-trainable params\n", |
| 8607 | + "13.5 K Total params\n", |
| 8608 | + "0.054 Total estimated model params size (MB)\n", |
| 8609 | + "17 Modules in train mode\n", |
| 8610 | + "0 Modules in eval mode\n", |
| 8611 | + "/Users/bartz/miniforge3/envs/spot312/lib/python3.12/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:424: The 'val_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=23` in the `DataLoader` to improve performance.\n", |
| 8612 | + "/Users/bartz/miniforge3/envs/spot312/lib/python3.12/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:424: The 'train_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=23` in the `DataLoader` to improve performance.\n", |
| 8613 | + "/Users/bartz/miniforge3/envs/spot312/lib/python3.12/site-packages/lightning/pytorch/loops/fit_loop.py:298: The number of training batches (5) is smaller than the logging interval Trainer(log_every_n_steps=50). Set a lower value for log_every_n_steps if you want to see logs for the training epoch.\n" |
| 8614 | + ] |
| 8615 | + }, |
| 8616 | + { |
| 8617 | + "name": "stdout", |
| 8618 | + "output_type": "stream", |
| 8619 | + "text": [ |
| 8620 | + "train_model result: {'val_loss': 23962.169921875, 'hp_metric': 23962.169921875}\n" |
| 8621 | + ] |
| 8622 | + }, |
| 8623 | + { |
| 8624 | + "name": "stderr", |
| 8625 | + "output_type": "stream", |
| 8626 | + "text": [ |
| 8627 | + "`Trainer.fit` stopped: `max_epochs=4` reached.\n" |
| 8628 | + ] |
| 8629 | + }, |
| 8630 | + { |
| 8631 | + "name": "stdout", |
| 8632 | + "output_type": "stream", |
| 8633 | + "text": [ |
| 8634 | + "train_model result: {'val_loss': 17713.64453125, 'hp_metric': 17713.64453125}\n", |
| 8635 | + "spotpython tuning: 17713.64453125 [########--] 80.00% \n" |
| 8636 | + ] |
| 8637 | + }, |
| 8638 | + { |
| 8639 | + "name": "stderr", |
| 8640 | + "output_type": "stream", |
| 8641 | + "text": [ |
| 8642 | + "/Users/bartz/miniforge3/envs/spot312/lib/python3.12/site-packages/lightning/pytorch/utilities/parsing.py:208: Attribute 'act_fn' is an instance of `nn.Module` and is already saved during checkpointing. It is recommended to ignore them using `self.save_hyperparameters(ignore=['act_fn'])`.\n", |
| 8643 | + "GPU available: True (mps), used: True\n", |
| 8644 | + "TPU available: False, using: 0 TPU cores\n", |
| 8645 | + "HPU available: False, using: 0 HPUs\n", |
| 8646 | + "\n", |
| 8647 | + " | Name | Type | Params | Mode | In sizes | Out sizes\n", |
| 8648 | + "---------------------------------------------------------------------\n", |
| 8649 | + "0 | layers | Sequential | 13.5 K | train | [32, 10] | [32, 1] \n", |
| 8650 | + "---------------------------------------------------------------------\n", |
| 8651 | + "13.5 K Trainable params\n", |
| 8652 | + "0 Non-trainable params\n", |
| 8653 | + "13.5 K Total params\n", |
| 8654 | + "0.054 Total estimated model params size (MB)\n", |
| 8655 | + "17 Modules in train mode\n", |
| 8656 | + "0 Modules in eval mode\n", |
| 8657 | + "/Users/bartz/miniforge3/envs/spot312/lib/python3.12/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:424: The 'val_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=23` in the `DataLoader` to improve performance.\n", |
| 8658 | + "/Users/bartz/miniforge3/envs/spot312/lib/python3.12/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:424: The 'train_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=23` in the `DataLoader` to improve performance.\n", |
| 8659 | + "/Users/bartz/miniforge3/envs/spot312/lib/python3.12/site-packages/lightning/pytorch/loops/fit_loop.py:298: The number of training batches (5) is smaller than the logging interval Trainer(log_every_n_steps=50). Set a lower value for log_every_n_steps if you want to see logs for the training epoch.\n", |
| 8660 | + "`Trainer.fit` stopped: `max_epochs=4` reached.\n" |
| 8661 | + ] |
| 8662 | + }, |
| 8663 | + { |
| 8664 | + "name": "stdout", |
| 8665 | + "output_type": "stream", |
| 8666 | + "text": [ |
| 8667 | + "train_model result: {'val_loss': 18886.90625, 'hp_metric': 18886.90625}\n", |
| 8668 | + "spotpython tuning: 17713.64453125 [##########] 100.00% Done...\n", |
| 8669 | + "\n", |
| 8670 | + "Experiment saved to show_exp_table_res.pkl\n", |
| 8671 | + "| name | type | default | lower | upper | tuned | transform | importance | stars |\n", |
| 8672 | + "|----------------|--------|-----------|---------|---------|----------------------|-----------------------|--------------|---------|\n", |
| 8673 | + "| l1 | int | 3 | 1.0 | 2.0 | 2.0 | transform_power_2_int | 29.49 | * |\n", |
| 8674 | + "| epochs | int | 4 | 2.0 | 2.0 | 2.0 | transform_power_2_int | 0.00 | |\n", |
| 8675 | + "| batch_size | int | 4 | 4.0 | 11.0 | 5.0 | transform_power_2_int | 1.18 | * |\n", |
| 8676 | + "| act_fn | factor | ReLU | 0.0 | 5.0 | ELU | None | 0.32 | . |\n", |
| 8677 | + "| optimizer | factor | SGD | 0.0 | 2.0 | Adam | None | 0.08 | |\n", |
| 8678 | + "| dropout_prob | float | 0.01 | 0.0 | 0.025 | 0.010464684336704316 | None | 0.27 | . |\n", |
| 8679 | + "| lr_mult | float | 1.0 | 0.1 | 10.0 | 8.82569482726512 | None | 9.55 | * |\n", |
| 8680 | + "| patience | int | 2 | 1.0 | 2.0 | 2.0 | transform_power_2_int | 100.00 | *** |\n", |
| 8681 | + "| batch_norm | factor | 0 | 0.0 | 1.0 | 0 | None | 0.05 | |\n", |
| 8682 | + "| initialization | factor | Default | 0.0 | 4.0 | kaiming_normal | None | 1.07 | * |\n" |
| 8683 | + ] |
| 8684 | + } |
| 8685 | + ], |
| 8686 | + "source": [ |
| 8687 | + "from spotpython.data.diabetes import Diabetes\n", |
| 8688 | + "from spotpython.hyperdict.light_hyper_dict import LightHyperDict\n", |
| 8689 | + "from spotpython.fun.hyperlight import HyperLight\n", |
| 8690 | + "from spotpython.utils.init import fun_control_init, design_control_init\n", |
| 8691 | + "from spotpython.spot import Spot\n", |
| 8692 | + "from spotpython.utils.eda import print_res_table\n", |
| 8693 | + "from spotpython.hyperparameters.values import set_hyperparameter\n", |
| 8694 | + "\n", |
| 8695 | + "fun_control = fun_control_init(\n", |
| 8696 | + " PREFIX=\"show_exp_table\",\n", |
| 8697 | + " fun_evals=5,\n", |
| 8698 | + " max_time=1,\n", |
| 8699 | + " data_set = Diabetes(),\n", |
| 8700 | + " core_model_name=\"light.regression.NNLinearRegressor\",\n", |
| 8701 | + " hyperdict=LightHyperDict,\n", |
| 8702 | + " _L_in=10,\n", |
| 8703 | + " _L_out=1)\n", |
| 8704 | + "\n", |
| 8705 | + "set_hyperparameter(fun_control, \"optimizer\", [ \"Adadelta\", \"Adam\", \"Adamax\"])\n", |
| 8706 | + "set_hyperparameter(fun_control, \"l1\", [1,2])\n", |
| 8707 | + "set_hyperparameter(fun_control, \"epochs\", [2,2])\n", |
| 8708 | + "set_hyperparameter(fun_control, \"batch_size\", [4,11])\n", |
| 8709 | + "set_hyperparameter(fun_control, \"dropout_prob\", [0.0, 0.025])\n", |
| 8710 | + "set_hyperparameter(fun_control, \"patience\", [1,2])\n", |
| 8711 | + "design_control = design_control_init(init_size=3)\n", |
| 8712 | + "\n", |
| 8713 | + "fun = HyperLight().fun\n", |
| 8714 | + "\n", |
| 8715 | + "S = Spot(fun=fun, fun_control=fun_control, design_control=design_control)\n", |
| 8716 | + "\n", |
| 8717 | + "S.run()\n", |
| 8718 | + "\n", |
| 8719 | + "print_res_table(S)" |
| 8720 | + ] |
| 8721 | + }, |
8416 | 8722 | { |
8417 | 8723 | "cell_type": "code", |
8418 | 8724 | "execution_count": null, |
|
0 commit comments