BUG FIX: add needed imports to utils
[notebooks.git] / fmda / rnn_hyperparam_tuning.ipynb
blob556e3bcd515b6c0f92c0f6ccfb5ae630593bb361
2  "cells": [
3   {
4    "cell_type": "code",
5    "execution_count": null,
6    "id": "4988786f-6672-46b7-b837-172f57dbf986",
7    "metadata": {},
8    "outputs": [],
9    "source": [
10     "from sklearn.model_selection import ParameterGrid"
11    ]
12   },
13   {
14    "cell_type": "code",
15    "execution_count": null,
16    "id": "b6fb2286-77ae-4905-8d4f-b40b305b53ea",
17    "metadata": {},
18    "outputs": [],
19    "source": [
20     "import yaml\n",
21     "\n",
22     "with open(\"params.yaml\") as file:\n",
23     "    params = yaml.safe_load(file)[\"rnn\"]\n",
24     "params.update({'scale': 1})\n",
25     "params"
26    ]
27   },
28   {
29    "cell_type": "code",
30    "execution_count": null,
31    "id": "ee18a132-de42-4665-88f6-fc6944e7e23a",
32    "metadata": {},
33    "outputs": [],
34    "source": [
35     "param_grids = {\n",
36     "    'batch_size': [12, 24, 32, 48],\n",
37     "    'timesteps': [3, 5, 8, 10],\n",
38     "    'rnn_units': [3, 6, 12, 15, 20],\n",
39     "    'activation': [['linear', 'linear'], ['relu', 'relu'], ['sigmoid', 'sigmoid'], ['sigmoid', 'relu']],\n",
40     "    'dropout': [[0.0,0.0], [0.0,0.2], [0.2,0.0], [0.2,0.2], [0.4,0.4]],\n",
41     "    'recurrent_dropout': [0.0, 0.1, 0.2, 0.4],\n",
42     "    'epochs': [20, 50, 100, 200, 500],\n",
43     "    'learning_rate': [0.0001, 0.001, 0.01, 0.1]\n",
44     "}"
45    ]
46   },
47   {
48    "cell_type": "code",
49    "execution_count": null,
50    "id": "3d2130b4-a085-419c-b8e5-6fe46755e9b6",
51    "metadata": {},
52    "outputs": [],
53    "source": [
54     "print(len(list(ParameterGrid(param_grids))))\n",
55     "list(ParameterGrid(param_grids))[0:5]"
56    ]
57   },
58   {
59    "cell_type": "code",
60    "execution_count": null,
61    "id": "cf962e03-8154-4aca-b11e-64b2d8101b27",
62    "metadata": {},
63    "outputs": [],
64    "source": []
65   }
66  ],
67  "metadata": {
68   "kernelspec": {
69    "display_name": "Python 3 (ipykernel)",
70    "language": "python",
71    "name": "python3"
72   },
73   "language_info": {
74    "codemirror_mode": {
75     "name": "ipython",
76     "version": 3
77    },
78    "file_extension": ".py",
79    "mimetype": "text/x-python",
80    "name": "python",
81    "nbconvert_exporter": "python",
82    "pygments_lexer": "ipython3",
83    "version": "3.9.12"
84   }
85  },
86  "nbformat": 4,
87  "nbformat_minor": 5