Update rnn_workshop.ipynb
[notebooks.git] / fmda / rnn_hyperparam_tuning.ipynb
blob17e83a6b7a84fd210e369e6cbe112e479e62fae4
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     "    'clipvalue': [[1], [2], [3], [4], [5]],\n",
42     "    'recurrent_dropout': [0.0, 0.1, 0.2, 0.4],\n",
43     "    'epochs': [20, 50, 100, 200, 500],\n",
44     "    'learning_rate': [0.0001, 0.001, 0.01, 0.1]\n",
45     "}"
46    ]
47   },
48   {
49    "cell_type": "code",
50    "execution_count": null,
51    "id": "3d2130b4-a085-419c-b8e5-6fe46755e9b6",
52    "metadata": {},
53    "outputs": [],
54    "source": [
55     "print(len(list(ParameterGrid(param_grids))))\n",
56     "list(ParameterGrid(param_grids))[0:5]"
57    ]
58   },
59   {
60    "cell_type": "code",
61    "execution_count": null,
62    "id": "cf962e03-8154-4aca-b11e-64b2d8101b27",
63    "metadata": {},
64    "outputs": [],
65    "source": []
66   }
67  ],
68  "metadata": {
69   "kernelspec": {
70    "display_name": "Python 3 (ipykernel)",
71    "language": "python",
72    "name": "python3"
73   },
74   "language_info": {
75    "codemirror_mode": {
76     "name": "ipython",
77     "version": 3
78    },
79    "file_extension": ".py",
80    "mimetype": "text/x-python",
81    "name": "python",
82    "nbconvert_exporter": "python",
83    "pygments_lexer": "ipython3",
84    "version": "3.12.5"
85   }
86  },
87  "nbformat": 4,
88  "nbformat_minor": 5