Skip to content

Commit 578b9ff

Browse files
committed
Create lstm_check_model_parameter_count.ipynb
1 parent f9f79fd commit 578b9ff

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import tensorflow as tf\n",
10+
"from tensorflow import keras\n",
11+
"from keras import layers"
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": null,
17+
"metadata": {},
18+
"outputs": [],
19+
"source": [
20+
"Nt = 4096\n",
21+
"Nx = 64\n",
22+
"Nh = 130\n",
23+
"\n",
24+
"model = keras.Sequential(\n",
25+
" [\n",
26+
" layers.Input(shape=(Nt, Nx)),\n",
27+
" layers.LSTM(Nh, return_sequences=True)\n",
28+
" ])\n",
29+
"model.summary()\n",
30+
"print(4 * Nh*Nx + 4 * Nh*Nh + 4 * Nh*1, 4 * Nh * (Nx + Nh + 1))\n",
31+
"\n",
32+
"model = keras.Sequential(\n",
33+
" [\n",
34+
" layers.Input(shape=(Nt, Nx)),\n",
35+
" layers.Bidirectional(layers.LSTM(Nh, return_sequences=True))\n",
36+
" ])\n",
37+
"model.summary()\n",
38+
"print(2 * (4 * Nh*Nx + 4 * Nh*Nh + 4 * Nh*1), 2 * 4 * Nh * (Nx + Nh + 1))\n"
39+
]
40+
}
41+
],
42+
"metadata": {
43+
"kernelspec": {
44+
"display_name": "myddasp",
45+
"language": "python",
46+
"name": "myddasp"
47+
},
48+
"language_info": {
49+
"codemirror_mode": {
50+
"name": "ipython",
51+
"version": 3
52+
},
53+
"file_extension": ".py",
54+
"mimetype": "text/x-python",
55+
"name": "python",
56+
"nbconvert_exporter": "python",
57+
"pygments_lexer": "ipython3",
58+
"version": "3.11.0"
59+
}
60+
},
61+
"nbformat": 4,
62+
"nbformat_minor": 4
63+
}

0 commit comments

Comments
 (0)