|
28 | 28 | }, |
29 | 29 | { |
30 | 30 | "cell_type": "code", |
31 | | - "execution_count": 1, |
| 31 | + "execution_count": null, |
32 | 32 | "metadata": { |
33 | 33 | "ExecuteTime": { |
34 | 34 | "end_time": "2025-02-14T10:51:27.573003Z", |
35 | 35 | "start_time": "2025-02-14T10:51:27.568939Z" |
36 | 36 | } |
37 | 37 | }, |
38 | | - "outputs": [ |
39 | | - { |
40 | | - "name": "stderr", |
41 | | - "output_type": "stream", |
42 | | - "text": [ |
43 | | - "WARNING:bayesflow:\n", |
44 | | - "When using torch backend, we need to disable autograd by default to avoid excessive memory usage. Use\n", |
45 | | - "\n", |
46 | | - "with torch.enable_grad():\n", |
47 | | - " ...\n", |
48 | | - "\n", |
49 | | - "in contexts where you need gradients (e.g. custom training loops).\n" |
50 | | - ] |
51 | | - } |
52 | | - ], |
| 38 | + "outputs": [], |
53 | 39 | "source": [ |
54 | 40 | "import numpy as np\n", |
| 41 | + "from pathlib import Path\n", |
55 | 42 | "\n", |
56 | 43 | "import keras\n", |
57 | 44 | "import bayesflow as bf" |
|
598 | 585 | }, |
599 | 586 | { |
600 | 587 | "cell_type": "code", |
601 | | - "execution_count": 19, |
| 588 | + "execution_count": null, |
602 | 589 | "metadata": { |
603 | 590 | "ExecuteTime": { |
604 | 591 | "end_time": "2025-02-14T10:52:51.132695Z", |
|
618 | 605 | } |
619 | 606 | ], |
620 | 607 | "source": [ |
621 | | - "f = bf.diagnostics.plots.loss(history, )" |
| 608 | + "f = bf.diagnostics.plots.loss(history)" |
622 | 609 | ] |
623 | 610 | }, |
624 | 611 | { |
|
964 | 951 | }, |
965 | 952 | { |
966 | 953 | "cell_type": "code", |
967 | | - "execution_count": 30, |
| 954 | + "execution_count": null, |
968 | 955 | "metadata": {}, |
969 | | - "outputs": [ |
970 | | - { |
971 | | - "name": "stderr", |
972 | | - "output_type": "stream", |
973 | | - "text": [ |
974 | | - "2025-04-21 11:54:04.969579: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.\n", |
975 | | - "2025-04-21 11:54:04.977366: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:467] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n", |
976 | | - "WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n", |
977 | | - "E0000 00:00:1745250844.984817 4140753 cuda_dnn.cc:8579] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n", |
978 | | - "E0000 00:00:1745250844.987174 4140753 cuda_blas.cc:1407] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n", |
979 | | - "W0000 00:00:1745250844.993850 4140753 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", |
980 | | - "W0000 00:00:1745250844.993860 4140753 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", |
981 | | - "W0000 00:00:1745250844.993861 4140753 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", |
982 | | - "W0000 00:00:1745250844.993863 4140753 computation_placer.cc:177] computation placer already registered. Please check linkage and avoid linking the same target more than once.\n", |
983 | | - "2025-04-21 11:54:04.996047: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n", |
984 | | - "To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n" |
985 | | - ] |
986 | | - } |
987 | | - ], |
| 956 | + "outputs": [], |
988 | 957 | "source": [ |
989 | 958 | "# Recommended - full serialization (checkpoints folder must exist)\n", |
990 | | - "workflow.approximator.save(filepath=\"checkpoints/regression.keras\")\n", |
| 959 | + "filepath = Path(\"checkpoints\") / \"regression.keras\"\n", |
| 960 | + "filepath.parent.mkdir(exist_ok=True)\n", |
| 961 | + "workflow.approximator.save(filepath=filepath)\n", |
991 | 962 | "\n", |
992 | 963 | "# Not recommended due to adapter mismatches - weights only\n", |
993 | 964 | "# approximator.save_weights(filepath=\"checkpoints/regression.h5\")" |
|
1002 | 973 | }, |
1003 | 974 | { |
1004 | 975 | "cell_type": "code", |
1005 | | - "execution_count": 31, |
| 976 | + "execution_count": null, |
1006 | 977 | "metadata": {}, |
1007 | | - "outputs": [ |
1008 | | - { |
1009 | | - "name": "stderr", |
1010 | | - "output_type": "stream", |
1011 | | - "text": [ |
1012 | | - "/home/radevs/anaconda3/envs/bf/lib/python3.11/site-packages/keras/src/saving/serialization_lib.py:734: UserWarning: `compile()` was not called as part of model loading because the model's `compile()` method is custom. All subclassed Models that have `compile()` overridden should also override `get_compile_config()` and `compile_from_config(config)`. Alternatively, you can call `compile()` manually after loading.\n", |
1013 | | - " instance.compile_from_config(compile_config)\n" |
1014 | | - ] |
1015 | | - } |
1016 | | - ], |
| 978 | + "outputs": [], |
1017 | 979 | "source": [ |
1018 | 980 | "# Load approximator\n", |
1019 | | - "approximator = keras.saving.load_model(\"checkpoints/regression.keras\")" |
| 981 | + "approximator = keras.saving.load_model(filepath)" |
1020 | 982 | ] |
1021 | 983 | }, |
1022 | 984 | { |
|
1052 | 1014 | " variable_names=par_names\n", |
1053 | 1015 | ")" |
1054 | 1016 | ] |
1055 | | - }, |
1056 | | - { |
1057 | | - "cell_type": "code", |
1058 | | - "execution_count": null, |
1059 | | - "metadata": {}, |
1060 | | - "outputs": [], |
1061 | | - "source": [] |
1062 | 1017 | } |
1063 | 1018 | ], |
1064 | 1019 | "metadata": { |
|
1073 | 1028 | "name": "python3" |
1074 | 1029 | }, |
1075 | 1030 | "language_info": { |
1076 | | - "codemirror_mode": { |
1077 | | - "name": "ipython", |
1078 | | - "version": 3 |
1079 | | - }, |
1080 | | - "file_extension": ".py", |
1081 | | - "mimetype": "text/x-python", |
1082 | | - "name": "python", |
1083 | | - "nbconvert_exporter": "python", |
1084 | | - "pygments_lexer": "ipython3", |
1085 | | - "version": "3.11.11" |
| 1031 | + "name": "python" |
1086 | 1032 | }, |
1087 | 1033 | "widgets": { |
1088 | 1034 | "application/vnd.jupyter.widget-state+json": { |
|
0 commit comments