Skip to content

Commit

Permalink
Create lstm_check_model_parameter_count.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
fs446 committed Oct 11, 2024
1 parent f9f79fd commit 578b9ff
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions lstm_check_model_parameter_count.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import tensorflow as tf\n",
"from tensorflow import keras\n",
"from keras import layers"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Nt = 4096\n",
"Nx = 64\n",
"Nh = 130\n",
"\n",
"model = keras.Sequential(\n",
" [\n",
" layers.Input(shape=(Nt, Nx)),\n",
" layers.LSTM(Nh, return_sequences=True)\n",
" ])\n",
"model.summary()\n",
"print(4 * Nh*Nx + 4 * Nh*Nh + 4 * Nh*1, 4 * Nh * (Nx + Nh + 1))\n",
"\n",
"model = keras.Sequential(\n",
" [\n",
" layers.Input(shape=(Nt, Nx)),\n",
" layers.Bidirectional(layers.LSTM(Nh, return_sequences=True))\n",
" ])\n",
"model.summary()\n",
"print(2 * (4 * Nh*Nx + 4 * Nh*Nh + 4 * Nh*1), 2 * 4 * Nh * (Nx + Nh + 1))\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "myddasp",
"language": "python",
"name": "myddasp"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

0 comments on commit 578b9ff

Please sign in to comment.