|
857 | 857 | ] |
858 | 858 | }, |
859 | 859 | { |
| 860 | + "attachments": {}, |
860 | 861 | "cell_type": "markdown", |
861 | 862 | "metadata": {}, |
862 | 863 | "source": [ |
|
905 | 906 | "\n", |
906 | 907 | "### Loss Functions and Metrics\n", |
907 | 908 | "\n", |
908 | | - "The key `\"criterion\"` specifies the loss function which is used during the optimization. There are several different loss functions under `PyTorch`'s nn package. For example, a simple loss is `MSELoss`, which computes the mean-squared error between the output and the target. In this tutorial we will use `CrossEntropyLoss`, because it is also used in the `PyTorch` tutorial." |
| 909 | + "::: {.callout-warning}\n", |
| 910 | + "#### Use of the Key `\"criterion\"` is deprecated as of `v.0.1.5`\n", |
| 911 | + "Starting with version `v.0.1.5` `spotPython` uses the key `\"loss_function\"` for loss functions instead of `\"criterion\"`.\n", |
| 912 | + ":::\n", |
| 913 | + "\n", |
| 914 | + "The key `\"loss_function\"` specifies the loss function which is used during the optimization. There are several different loss functions under `PyTorch`'s nn package. For example, a simple loss is `MSELoss`, which computes the mean-squared error between the output and the target. In this tutorial we will use `CrossEntropyLoss`, because it is also used in the `PyTorch` tutorial." |
909 | 915 | ] |
910 | 916 | }, |
911 | 917 | { |
|
914 | 920 | "metadata": {}, |
915 | 921 | "outputs": [], |
916 | 922 | "source": [ |
917 | | - "fun_control = modify_hyper_parameter_levels(fun_control, \"criterion\", [\"CrossEntropyLoss\"])" |
| 923 | + "fun_control = modify_hyper_parameter_levels(fun_control, \"loss_function\", [\"CrossEntropyLoss\"])" |
918 | 924 | ] |
919 | 925 | }, |
920 | 926 | { |
|
933 | 939 | "source": [ |
934 | 940 | "#| echo: true\n", |
935 | 941 | "weights = 1.0\n", |
936 | | - "criterion = CrossEntropyLoss\n", |
| 942 | + "loss_function = CrossEntropyLoss\n", |
937 | 943 | "shuffle = True\n", |
938 | 944 | "eval = \"train_hold_out\"\n", |
939 | 945 | "device = DEVICE\n", |
|
952 | 958 | " \"weight_coeff\": None,\n", |
953 | 959 | " \"metric\": None,\n", |
954 | 960 | " \"metric_sklearn\": None,\n", |
955 | | - " \"criterion\": criterion,\n", |
| 961 | + " \"loss_function\": loss_function,\n", |
956 | 962 | " \"shuffle\": shuffle,\n", |
957 | 963 | " \"eval\": eval,\n", |
958 | 964 | " \"device\": device,\n", |
|
2265 | 2271 | ] |
2266 | 2272 | }, |
2267 | 2273 | { |
| 2274 | + "attachments": {}, |
2268 | 2275 | "cell_type": "markdown", |
2269 | 2276 | "metadata": {}, |
2270 | 2277 | "source": [ |
|
2273 | 2280 | "```{raw}\n", |
2274 | 2281 | "config: {'l1': 64, 'l2': 32, 'lr': 0.008391430243550081, \n", |
2275 | 2282 | " 'batch_size': 4, 'epochs': 16, 'k_folds': 0, 'patience': 3,\n", |
2276 | | - " 'optimizer': 'Adam', 'criterion': CrossEntropyLoss()}\n", |
| 2283 | + " 'optimizer': 'Adam', 'loss_function': CrossEntropyLoss()}\n", |
2277 | 2284 | "Epoch: 9\n", |
2278 | 2285 | "Batch: 1000. Batch Size: 4. Training Loss (running): 2.308\n", |
2279 | 2286 | "Batch: 2000. Batch Size: 4. Training Loss (running): 1.153\n", |
|
0 commit comments