Skip to content

Instantly share code, notes, and snippets.

@FinanceData
Last active June 6, 2021 15:02
Show Gist options
  • Save FinanceData/f2ba3b4385754e1596f25ae27fae6efa to your computer and use it in GitHub Desktop.
Save FinanceData/f2ba3b4385754e1596f25ae27fae6efa to your computer and use it in GitHub Desktop.
Keras 08 - LSTM - 다양한 구성.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Keras 08 - LSTM - 다양한 구성.ipynb",
"provenance": [],
"collapsed_sections": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/FinanceData/f2ba3b4385754e1596f25ae27fae6efa/notebook.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "NevktENNyu5d"
},
"source": [
"# Keras - LSTM - 다양한 구성\n",
"\n",
"<img width=\"40%\" src=\"https://imgur.com/ZZUfQco.png\">\n",
"\n",
"**2019-2021 [FinanceData.KR](http://financedata.kr) | [facebook.com/financedata](http://facebook.com/financedata)**"
]
},
{
"cell_type": "code",
"metadata": {
"id": "6l7fJTDHBbIK"
},
"source": [
"import numpy as np\n",
"import pandas as pd"
],
"execution_count": 29,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "e0_soJrrkdF6"
},
"source": [
"# LSTM\n",
"입력 (batch_size, timesteps, input_dim) 형태의 3D 텐서\n",
"\n",
"* units: 출력수\n",
"* activation: 활성함수(기본값: `tanh`)\n",
"* stateful: batch내 마지막 상태를 다음 batch의 초기 값으로 전달 (기본값: False) \n",
"\n",
"\n",
"```python\n",
"model = Sequential()\n",
"model.add(LSTM(128, input_shape=(4, 1)))\n",
"model.add(Dense(one_hot_vec_size, activation='softmax'))\n",
"```\n",
"\n",
"\n",
"batch_input_shape"
]
},
{
"cell_type": "code",
"metadata": {
"id": "wm5TJm3XnpVP",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "45c14783-6168-4ed9-ceb3-e631c3aa0fb0"
},
"source": [
"from tensorflow.keras.layers import LSTM\n",
"\n",
"inputs = np.random.random([10, 5, 8]).astype(np.float32)\n",
"lstm = LSTM(4)\n",
"\n",
"output = lstm(inputs) # The output has shape `[10, 4]`.\n",
"output"
],
"execution_count": 30,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<tf.Tensor: shape=(10, 4), dtype=float32, numpy=\n",
"array([[ 0.20688331, -0.33569196, -0.26950288, -0.32427326],\n",
" [ 0.23900172, -0.3384517 , -0.3084644 , -0.3237447 ],\n",
" [ 0.20406622, -0.38868618, -0.3222125 , -0.37952414],\n",
" [ 0.13626516, -0.3892799 , -0.18139675, -0.37758175],\n",
" [ 0.24495627, -0.4281433 , -0.28752932, -0.3744105 ],\n",
" [ 0.28998747, -0.29479292, -0.24098292, -0.31863555],\n",
" [ 0.18514459, -0.33741927, -0.26141754, -0.3624317 ],\n",
" [ 0.14366014, -0.34975567, -0.23518541, -0.34933624],\n",
" [ 0.24872026, -0.29057756, -0.23649417, -0.31782204],\n",
" [ 0.18731515, -0.34731048, -0.2634387 , -0.35081065]],\n",
" dtype=float32)>"
]
},
"metadata": {
"tags": []
},
"execution_count": 30
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "UoU3W9_voNx7"
},
"source": [
"from tensorflow.keras.models import Sequential\n",
"from tensorflow.keras.layers import LSTM\n",
"\n",
"lstm = LSTM(4, return_sequences=True, return_state=True)\n",
"\n",
"# whole_sequence_output has shape `[32, 10, 4]`.\n",
"# final_memory_state and final_carry_state both have shape `[32, 4]`.\n",
"whole_sequence_output, final_memory_state, final_carry_state = lstm(inputs)"
],
"execution_count": 31,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "DQSLub0hpdAH",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "04801218-3203-4d8f-b72b-125fcd283771"
},
"source": [
"final_carry_state"
],
"execution_count": 32,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<tf.Tensor: shape=(10, 4), dtype=float32, numpy=\n",
"array([[-0.23477821, -0.2561686 , -1.1772712 , -0.07495873],\n",
" [-0.32611296, -0.17704253, -1.3611389 , -0.0666235 ],\n",
" [ 0.04244636, -0.45983917, -1.2444476 , -0.24431005],\n",
" [-0.27068228, -0.5197038 , -1.2941011 , -0.23620991],\n",
" [-0.22558141, -0.46686926, -1.1262234 , -0.22825663],\n",
" [-0.12436227, -0.4464874 , -1.1424009 , -0.22110598],\n",
" [-0.07241282, -0.43684483, -1.1626145 , -0.18896072],\n",
" [-0.24880418, -0.46992603, -1.3002108 , -0.27417603],\n",
" [-0.27308583, -0.5517089 , -1.3240043 , -0.3272207 ],\n",
" [-0.04194528, -0.33178303, -1.2448735 , -0.095449 ]],\n",
" dtype=float32)>"
]
},
"metadata": {
"tags": []
},
"execution_count": 32
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "SBcQlUVyjb7U"
},
"source": [
"# LSTM 구성 조합\n",
"n-to-m, Direction, Layered 등에 따라 다양한 조합이 가능하다\n",
"\n",
"1. **n-to-m** : many-to-one, many-to-many, one-to-many\n",
"1. **Direction** : Unidirectional(단방향), Bidirectional (양방향)\n",
"1. **Layered** : Single-layered, Multi-layered (Stacked)\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "tyA0ZGv7PksA"
},
"source": [
"# many-to-one LSTM"
]
},
{
"cell_type": "code",
"metadata": {
"id": "odA7XzY7QOGV",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "81b1cf29-e93e-4e7f-ae59-7cdc1412c57a"
},
"source": [
"from tensorflow.keras.models import Sequential\n",
"from tensorflow.keras.layers import Dense, LSTM\n",
"\n",
"x = np.array([[[1],[2],[3],[4]]])\n",
"y = np.array([[5]])\n",
"\n",
"model = Sequential()\n",
"model.add(LSTM(8, input_shape=(4, 1)))\n",
"model.add(Dense(1))\n",
"model.compile(loss='mse', optimizer='adam')\n",
"\n",
"model.summary()"
],
"execution_count": 33,
"outputs": [
{
"output_type": "stream",
"text": [
"Model: \"sequential_6\"\n",
"_________________________________________________________________\n",
"Layer (type) Output Shape Param # \n",
"=================================================================\n",
"lstm_12 (LSTM) (None, 8) 320 \n",
"_________________________________________________________________\n",
"dense_6 (Dense) (None, 1) 9 \n",
"=================================================================\n",
"Total params: 329\n",
"Trainable params: 329\n",
"Non-trainable params: 0\n",
"_________________________________________________________________\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "eUD2mzZoBlcA",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "4de4d608-d95a-4de1-b730-a2fb68793152"
},
"source": [
"x.shape, y.shape"
],
"execution_count": 34,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"((1, 4, 1), (1, 1))"
]
},
"metadata": {
"tags": []
},
"execution_count": 34
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "FxcuUuJkBNoy",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "56e8b31f-dc48-4d97-d555-3f4237802e8d"
},
"source": [
"hist = model.fit(x, y, epochs=500, batch_size=1, verbose=0)\n",
"model.predict(x, batch_size=1)"
],
"execution_count": 35,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[4.9985213]], dtype=float32)"
]
},
"metadata": {
"tags": []
},
"execution_count": 35
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "zHaSuR7LAkL8",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 282
},
"outputId": "18e35902-9638-444a-cc18-e756221bc460"
},
"source": [
"pd.DataFrame(hist.history).plot()"
],
"execution_count": 36,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f905981c6d0>"
]
},
"metadata": {
"tags": []
},
"execution_count": 36
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAfQUlEQVR4nO3deXxU9b3G8c93JkMSSAgQQgIECCAEkE0JiBuCIqJ1vWiV2qrVSluXutWt3lq9tddda63Vi1fqct1brFoURFxw14Dsu6xhDWEnZp3f/SMTGhFKlpmcWZ736zWvmTkzk/P8MD4czpzzO+acQ0REYo/P6wAiItI4KnARkRilAhcRiVEqcBGRGKUCFxGJUUnNubL27du7vLy85lyliEjMmzVr1lbnXNb+y5u1wPPy8igsLGzOVYqIxDwzW3Og5dqFIiISow5Z4GbWxczeN7NFZrbQzK4JLb/DzNab2ZzQ7bTIxxURkVr12YVSBdzgnJttZunALDObHnrtYefcA5GLJyIiB3PIAnfObQQ2hh7vNrPFQOdIBxMROZDKykqKioooKyvzOkrYpaSkkJubSyAQqNf7G/QlppnlAUcAXwDHAleZ2UVAITVb6dsP8JkJwASArl27NmR1IiLfU1RURHp6Onl5eZiZ13HCxjlHSUkJRUVFdO/evV6fqfeXmGaWBvwduNY5twt4HOgJDKZmC/3Bg4Sa6JwrcM4VZGV97ygYEZEGKSsrIzMzM67KG8DMyMzMbNC/LOpV4GYWoKa8n3fOTQZwzm12zlU754LAk8CwRmQWEWmweCvvWg0dV32OQjHgKWCxc+6hOss71nnbOcCCBq25AWav3c7jH3wTqR8vIhKT6rMP/FjgJ8B8M5sTWvYbYLyZDQYcsBr4eUQSAm/M2cDTn66mb8d0RuZ3iNRqRETqJS0tjT179ngdo15HoXwMHGi7/q3wxzmwW07tw+crS/j1q3N5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FKBS4iEqP+H97llq7OWZ72AAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"tags": [],
"needs_background": "light"
}
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "aCs8qCiXkSMQ"
},
"source": [
"# many-to-many LSTM "
]
},
{
"cell_type": "code",
"metadata": {
"id": "TsclZBkqRX3m",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "1bf9f239-61d5-461e-c30c-4f14494646f9"
},
"source": [
"from tensorflow.keras.models import Model\n",
"from tensorflow.keras.layers import Dense, LSTM, TimeDistributed\n",
"import numpy as np\n",
"\n",
"x = np.array([[[1], [2], [3], [4]]])\n",
"y = np.array([[[2], [3], [4], [5]]])\n",
"\n",
"model = Sequential()\n",
"model.add(LSTM(8, input_shape=(4, 1), return_sequences=True))\n",
"model.add(TimeDistributed(Dense(1)))\n",
"model.compile(loss='mse', optimizer='adam')\n",
"\n",
"model.summary()"
],
"execution_count": 37,
"outputs": [
{
"output_type": "stream",
"text": [
"Model: \"sequential_7\"\n",
"_________________________________________________________________\n",
"Layer (type) Output Shape Param # \n",
"=================================================================\n",
"lstm_13 (LSTM) (None, 4, 8) 320 \n",
"_________________________________________________________________\n",
"time_distributed_2 (TimeDist (None, 4, 1) 9 \n",
"=================================================================\n",
"Total params: 329\n",
"Trainable params: 329\n",
"Non-trainable params: 0\n",
"_________________________________________________________________\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "ejdqLOaFyIKL",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 282
},
"outputId": "37f67653-3031-43b8-e98f-e0677e3ccc3f"
},
"source": [
"hist = model.fit(x, y, epochs=500, batch_size=1, verbose=0)\n",
"\n",
"pd.DataFrame(hist.history).plot()"
],
"execution_count": 38,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f9058224b10>"
]
},
"metadata": {
"tags": []
},
"execution_count": 38
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAf80lEQVR4nO3deXxU9b3G8c93ZrKQjUASwk7YIaxqUBFFRVFE3Kq3Lm3VWsvtotXSq3WpVltbtfbWpbVWaq3trWurraiIAgpi6wYIsu9b2JIgW4CQZX73jxkwImrIzOTM8rxfr7xy5syZzPPD+HA48zvnmHMOERFJPD6vA4iISPOowEVEEpQKXEQkQanARUQSlApcRCRBBVryzQoLC11JSUlLvqWISMKbM2dOlXOu6ND1LVrgJSUlzJ49uyXfUkQk4ZnZusOt1yEUEZEEpQIXEUlQKnARkQTVosfARUQiVVdXR3l5OTU1NV5HibrMzEw6d+5MWlpak7ZXgYtIQikvLyc3N5eSkhLMzOs4UeOcY9u2bZSXl9O9e/cmvUaHUEQkodTU1FBQUJBU5Q1gZhQUFBzRvyxU4CKScJKtvA840nElRIFPX7KVZ95f73UMEZG4khAF/vT7G7h90iJWVuz2OoqICDk5OV5HABKkwH/5lYFkp/uZ8Nx86huCXscREYkLCVHg7XIzuev8QXxUvpNHZqzyOo6ICBCaOXLDDTcwcOBABg0axLPPPgvA5s2bGTlyJEOHDmXgwIHMmjWLhoYGrrzyyoPb3n///RG/f8JMIzx7cAemLOrIg9NXMKp/OwZ0bO11JBHx2J0vLWLxpl1R/ZmlHfP46TkDmrTtCy+8wLx585g/fz5VVVUMGzaMkSNH8tRTT3HmmWdy66230tDQwN69e5k3bx4bN25k4cKFAOzYsSPirAmxB37Az84dQJvsdH703Hz21zd4HUdEUtzbb7/NpZdeit/vp7i4mJNPPpkPPviAYcOG8ec//5k77riDBQsWkJubS48ePVi9ejXXXnstU6ZMI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+8GdxEfCGCx8kTRTOuZudc52dcyWE/n99wzn3NZJ4zGaWbWa5B5aBM4CFxPp32+sD/038cGAssJzQscNbvc4TxXE9DWwG6ggdA/sWoWN/04EVwDSgbXhbIzQbZxWwACjzOn8zxnsioeOEHwHzwl9jk3zMg4EPw2NeCNweXt8DeB9YCfwdyAivzww/Xhl+vofXY4hw/KcALyf7mMNjmx/+WnSgp2L9u61T6UVEElQiHEIREZHDUIGLiCQoFbiISIJSgYuIJCgVuIhIglKBi4gkKBW4iEiC+n+3RUmPUV0dBQAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"tags": [],
"needs_background": "light"
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "rVPJ0hYsyLs8",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "a411b549-6902-43c1-e124-74615b56aca7"
},
"source": [
"model.predict(x).flatten()"
],
"execution_count": 39,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([1.2686777, 3.0646281, 4.3462524, 4.721526 ], dtype=float32)"
]
},
"metadata": {
"tags": []
},
"execution_count": 39
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "32qyUjLbzAiq"
},
"source": [
"# Bidirectional LSTM\n",
"* 시퀀스 입력값에 대해 이전 데이터와 후 데이터와의 관계도 학습\n",
"* 두 개의 모델(순방향, 역방향)을 만들어 학습 결과를 합치(merge)는 모델\n",
"* Forward 레이어 + Backward 레이어\n",
" * Forward 레이어: 1→2→3→4 시퀀스 학습\n",
" * Backward 레이어: 1←2←3←4 시퀀스 학습\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "hZpYhfXxvk92"
},
"source": [
"# Bidirectional many-to-one LSTM"
]
},
{
"cell_type": "code",
"metadata": {
"id": "kWZZt1lXz21U",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "f8eeb97b-4aae-45e0-bea1-8c2c9fd83410"
},
"source": [
"from tensorflow.keras.models import Sequential\n",
"from tensorflow.keras.layers import Dense, LSTM, Bidirectional\n",
"import numpy as np\n",
"\n",
"x = np.array([[[1], [2], [3], [4]]])\n",
"y = np.array([[5]])\n",
"\n",
"model = Sequential()\n",
"model.add(Bidirectional(LSTM(8), input_shape=(4, 1), merge_mode='concat'))\n",
"model.add(Dense(1))\n",
"\n",
"model.compile(loss='mse', optimizer='adam')\n",
"\n",
"model.summary()"
],
"execution_count": 40,
"outputs": [
{
"output_type": "stream",
"text": [
"Model: \"sequential_8\"\n",
"_________________________________________________________________\n",
"Layer (type) Output Shape Param # \n",
"=================================================================\n",
"bidirectional_3 (Bidirection (None, 16) 640 \n",
"_________________________________________________________________\n",
"dense_8 (Dense) (None, 1) 17 \n",
"=================================================================\n",
"Total params: 657\n",
"Trainable params: 657\n",
"Non-trainable params: 0\n",
"_________________________________________________________________\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "7dXa_l7D2Y9k"
},
"source": [
"hist = model.fit(x, y, epochs=500, batch_size=1, verbose=0)"
],
"execution_count": 41,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "petPL7NZwyL7",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 282
},
"outputId": "86215314-faf8-48c0-9dcb-a0f88cf547e2"
},
"source": [
"pd.DataFrame(hist.history).plot()"
],
"execution_count": 42,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f90507d2fd0>"
]
},
"metadata": {
"tags": []
},
"execution_count": 42
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAekUlEQVR4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M3238C9QE1ouT2xPd4jHPC+mc0PTegOEfz5jvikxtJ0zjlnZjF3nqeZZQCvAz9wzu01s6OvxeqYnXNBYLCZtQH+BpzmcaSIMbNvANudc/PNbJTXeaLsPOdciZmdAnxgZivqvhjun28/7IHH2+TJpWbWCSD0dXtofUz8OZhZErXl/aJz7o3Q6pgec13Oud3ADGoPIbQxsyM7UXXHdnTcodezgPIoR22Oc4HLzWwD8DK1h1F+R+yO9yjnXEno63Zq/0c9jAj+fPuhwONt8uS3gBtDz2+k9jjxkfU3hH5zfRawp84/y3zBane1nwaWO+d+W+elmB0zgJllh/a8MbM0ao/7L6e2yK8NbXbsuI/8eVwL/MuFDpL6gXPufudcrnMuj9q/r/9yzn2HGB3vEWaWbmaZR54DFwFLieTPt9cH/Rv5i4FLgFXUHjd8wOs8YRzXX4CtwGFqj3/dTO2xv4+A1cCHQLvQtkbt2ThrgSVAodf5mzDe86g9RrgYWBh6XBLLYw6NYyDwZWjcS4H/F1pfAMwD1gCvAimh9amh5TWh1wu8HkMzxj4KeDsexhsa36LQY9mRrorkz7cupRcR8Sk/HEIREZF6qMBFRHxKBS4i4lMqcBERn1KBi4j4lApcRMSnVOAiIj71/wHEBwncMw6eGQAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"tags": [],
"needs_background": "light"
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "yqLmYeNA2gH_",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "db704eb9-786b-49ba-ac6e-ef175f246cf6"
},
"source": [
"model.predict(x)"
],
"execution_count": 43,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[5.000004]], dtype=float32)"
]
},
"metadata": {
"tags": []
},
"execution_count": 43
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "PoITN2an20lS"
},
"source": [
"# Bidirectional many-to-many LSTM\n",
"* LSTM return_sequences=True + Bidirectional\n",
"* TimeDistributed()\n"
]
},
{
"cell_type": "code",
"metadata": {
"id": "m3eHau213WmI",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "90b5b037-7228-45af-cbf6-76893c707a0a"
},
"source": [
"from tensorflow.keras.models import Sequential\n",
"from tensorflow.keras.layers import Dense, LSTM, Bidirectional\n",
"import numpy as np\n",
"\n",
"x = np.array([[[1], [2], [3], [4]]])\n",
"y = np.array([[[2], [3], [4], [5]]])\n",
"\n",
"model = Sequential()\n",
"model.add(Bidirectional(LSTM(8, return_sequences=True), input_shape=(4, 1), merge_mode='concat'))\n",
"model.add(TimeDistributed(Dense(1)))\n",
"\n",
"model.compile(loss='mse', optimizer='adam')\n",
"\n",
"model.summary()"
],
"execution_count": 44,
"outputs": [
{
"output_type": "stream",
"text": [
"Model: \"sequential_9\"\n",
"_________________________________________________________________\n",
"Layer (type) Output Shape Param # \n",
"=================================================================\n",
"bidirectional_4 (Bidirection (None, 4, 16) 640 \n",
"_________________________________________________________________\n",
"time_distributed_3 (TimeDist (None, 4, 1) 17 \n",
"=================================================================\n",
"Total params: 657\n",
"Trainable params: 657\n",
"Non-trainable params: 0\n",
"_________________________________________________________________\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "hzuF1Ajeweky"
},
"source": [
"hist = model.fit(x, y, epochs=500, batch_size=1, verbose=0)"
],
"execution_count": 45,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "TWrm1TzCwhJ9",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 282
},
"outputId": "2e43176c-f6b9-406e-8b53-f826cd720db0"
},
"source": [
"pd.DataFrame(hist.history).plot()"
],
"execution_count": 46,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f905bf0a5d0>"
]
},
"metadata": {
"tags": []
},
"execution_count": 46
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAA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XeIrwLocDM9mxEtR7b3nFH3s8HNnVw1GicCJxrZquAZwjvRrmf5B3vXs65msjzRsJ/qEfRjr/fiVDgqXbvzReB70Ref4fwfuI9878d+eT6eGBbq3+WJQQLb2o/DCx2zt3b6q2kHTOAmRVGtrwxsyzC+/0XEy7yiyOL7TvuPT+Pi4E3XWQnaSJwzt3qnCtxzpUS/v/1TefcN0jS8e5hZjlm1mnPa+DLwALa8/fb653+h/jBwFeBpYT3G97mdZ4YjutpYB3QTDg7AkwAAACXSURBVHj/15WE9/1NA5YBbwBdIssa4aNxVgBVQIXX+dsw3pMI7yOcD8yNPL6azGOOjGMY8GFk3AuA/43M7we8DywH/gZkROZnRqaXR97v5/UYohj7qcDLqTDeyPjmRR4L93RVe/5+61R6EZEElQi7UEREZD9U4CIiCUoFLiKSoFTgIiIJSgUuIpKgVOAiIglKBS4ikqD+P6ZBg3JLdY4qAAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"tags": [],
"needs_background": "light"
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "CjlD5V7HwhXl",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "03d8befd-625d-4e66-b1a4-c49010a0d1c6"
},
"source": [
"model.predict(x)"
],
"execution_count": 47,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[[1.9752381],\n",
" [3.066146 ],\n",
" [4.2643476],\n",
" [4.6654572]]], dtype=float32)"
]
},
"metadata": {
"tags": []
},
"execution_count": 47
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "wxKqj_3dwz7d"
},
"source": [
"# Stacked many-to-one LSTM\n",
"다음 레이어가 LSTM 레이어라면 return_sequences=True 를 지정한다 (모든 출력이 각 스텝으로 전달되어야 하기 때문)\n"
]
},
{
"cell_type": "code",
"metadata": {
"id": "gRHtFY6nxbFn",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "12c981ee-3d5f-4527-df84-7d521d8b5b10"
},
"source": [
"from tensorflow.keras.models import Sequential\n",
"from tensorflow.keras.layers import Dense, LSTM\n",
"\n",
"x = np.array([[[1],[2],[3],[4]]])\n",
"y = np.array([[5]])\n",
"\n",
"model = Sequential()\n",
"model.add(LSTM(8, input_shape=(4, 1), return_sequences=True))\n",
"model.add(LSTM(8))\n",
"model.add(Dense(1))\n",
"model.compile(loss='mse', optimizer='adam')\n",
"\n",
"model.summary()"
],
"execution_count": 48,
"outputs": [
{
"output_type": "stream",
"text": [
"Model: \"sequential_10\"\n",
"_________________________________________________________________\n",
"Layer (type) Output Shape Param # \n",
"=================================================================\n",
"lstm_16 (LSTM) (None, 4, 8) 320 \n",
"_________________________________________________________________\n",
"lstm_17 (LSTM) (None, 8) 544 \n",
"_________________________________________________________________\n",
"dense_10 (Dense) (None, 1) 9 \n",
"=================================================================\n",
"Total params: 873\n",
"Trainable params: 873\n",
"Non-trainable params: 0\n",
"_________________________________________________________________\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "iZ8oc5iLHjZ9"
},
"source": [
"hist = model.fit(x, y, epochs=500, batch_size=1, verbose=0)"
],
"execution_count": 49,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "5aLpSxqyHjfh",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 282
},
"outputId": "c74298b2-8482-4ea0-f037-cb73f55e14fd"
},
"source": [
"pd.DataFrame(hist.history).plot()"
],
"execution_count": 50,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f905a1c1450>"
]
},
"metadata": {
"tags": []
},
"execution_count": 50
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy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sLoE+AvhewEnbH/b9HszUHBCW7d9v2N+D5yT3zx5oE+19IQi51yVN70LKPKmE+pz8P6ZfCbwLknQZ284YRmwB5gDbAAOOOdavFXa9u1Yv73lB4H8nq04Yj8BvgqEvPl8Eru/RzngNTNb7N3QHbrx+93tNzWWrnPOOTNLuOM8zSwHeAb4knOu1syOLUvUPjvnWoFyM+sDPAeM9LmkbmNmnwD2OOcWm9nFftfTwy5wzu0ws37AHDNb03ZhtL/f8bAHnmw3T95tZsUA3vMerz0hPgczSyUc3k845571mhO6z2055w4ArxMeQuhjZkd3otr27Vi/veW9gb09XGokJgKfNLPNwO8JD6P8lMTt7zHOuR3e8x7Cf6gn0I3f73gI8GS7efILwM3e9M2Ex4mPtt/k/XJ9LnCwzT/L4oKFd7V/Bax2zv24zaKE7TOAmRV6e96YWSbhcf/VhIP8Om+1E/t99PO4Dvir8wZJ44Fz7hvOuUHOuVLC/7/+1Tn3aRK0v0eZWbaZ5R6dBi4DVtCd32+/B/07+MPANOADwuOG9/ldTxT79TugCmgmPP51G+Gxv3nAOmAukOeta4SPxtkAvA9U+F1/F/p7AeExwveAZd5jWiL32evHWGCp1+8VwLe89mHA34H1wNNAutee4c2v95YP87sPEfT9YuAvydBfr3/LvcfKo1nVnd9vnUovIhKn4mEIRURETkIBLiISpxTgIiJxSgEuIhKnFOAiInFKAS4iEqcU4CIicep/AQENe4j2FwW/AAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"tags": [],
"needs_background": "light"
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "NYpCmNq7Hmfk",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "31f3a0fe-b6cc-4ed2-de92-0a408a75039f"
},
"source": [
"model.predict(x)"
],
"execution_count": 51,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[4.98183]], dtype=float32)"
]
},
"metadata": {
"tags": []
},
"execution_count": 51
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "IQtltsHEHyR_"
},
"source": [
"# Bidirectional Stacked many-to-one LSTM\n",
"Bidirectional을 Stacked LSTM에 추가\n"
]
},
{
"cell_type": "code",
"metadata": {
"id": "sP2hAjFqHzU-",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "393b34d3-c1ae-488f-f68f-e91f6d96df12"
},
"source": [
"from tensorflow.keras.models import Sequential\n",
"from tensorflow.keras.layers import Dense, LSTM\n",
"\n",
"x = np.array([[[1],[2],[3],[4]]])\n",
"y = np.array([[5]])\n",
"\n",
"model = Sequential()\n",
"model.add(LSTM(8, input_shape=(4, 1), return_sequences=True))\n",
"model.add(Bidirectional(LSTM(8)))\n",
"model.add(Dense(1))\n",
"model.compile(loss='mse', optimizer='adam')\n",
"\n",
"model.summary()"
],
"execution_count": 52,
"outputs": [
{
"output_type": "stream",
"text": [
"Model: \"sequential_11\"\n",
"_________________________________________________________________\n",
"Layer (type) Output Shape Param # \n",
"=================================================================\n",
"lstm_18 (LSTM) (None, 4, 8) 320 \n",
"_________________________________________________________________\n",
"bidirectional_5 (Bidirection (None, 16) 1088 \n",
"_________________________________________________________________\n",
"dense_11 (Dense) (None, 1) 17 \n",
"=================================================================\n",
"Total params: 1,425\n",
"Trainable params: 1,425\n",
"Non-trainable params: 0\n",
"_________________________________________________________________\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "MzN9Xy-gHzVD"
},
"source": [
"hist = model.fit(x, y, epochs=500, batch_size=1, verbose=0)"
],
"execution_count": 53,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "rGRUrzZrHzVF",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 282
},
"outputId": "0d2523e2-31c2-4ae4-d5b6-c5e26109a64f"
},
"source": [
"pd.DataFrame(hist.history).plot()"
],
"execution_count": 54,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f905a1ef510>"
]
},
"metadata": {
"tags": []
},
"execution_count": 54
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAbd0lEQVR4nO3deXhV9b3v8fc3OxMkQJKdEBBIQgAFZAgkTFpBrArVc6qe+pyWTtpa9fTaHnvb66mt97k9fdrbWr2t9fa0emy16tFWa9XjUFtLrRNUkQQTZhmDBAIJYR4CGX73jyy4OQhm2MPaa+/P63ny7L3XXsn6/HD7YfHLGsw5h4iIBE+a3wFERKR/VOAiIgGlAhcRCSgVuIhIQKnARUQCKj2eGyssLHRlZWXx3KSISODV1NTscc4Vnb48rgVeVlZGdXV1PDcpIhJ4ZrbtTMs1hSIiElAqcBGRgFKBi4gEVFznwEVEItXW1kZDQwOtra1+R4m67OxsRo4cSUZGRq/W77HAzWwU8ChQDDjgAefcvWb2r8CNQLO36redcy/1K7WISC81NDQwaNAgysrKMDO/40SNc46WlhYaGhoYPXp0r76nN3vg7cA3nHMrzGwQUGNmi7337nHO/Z9+5hUR6bPW1takK28AMyMcDtPc3Nzzyp4eC9w51wg0es8Pmdk6YES/U4qIRCjZyvukvo6rT7/ENLMyYBqwzFv0FTNbaWYPmVl+n7bcB+++v4/7Xtscqx8vIhJIvS5wM8sFnga+5pw7CNwHjAEq6NpD//FZvu8mM6s2s+q+/NOgu+dqd/KjP63nj6sa+/X9IiLRlJub63cEoJcFbmYZdJX34865ZwCcc7udcx3OuU7gl8DMM32vc+4B51yVc66qqOgDZ4L2yrevmMC0kjz+x1N1bGo61K+fISKSbHoscOualHkQWOec+0m35cO7rXYNsDr68bpkpqfxi89MZ0BmiJv/o4bDx9tjtSkRkV5zznHbbbcxadIkJk+ez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oWv847yvm4D74pQxmtqBbzjnJgKzgVu8/5bJPGaA48AlzrmpQAWw0MxmAz8C7nHOjQX2ATd4698A7POW3+OtF0S3Auu6vU728Z403zlX0e2Y79h9vp1zCf0FzAFe7vb6W8C3/M4VxfGVAau7vX4PGO49Hw685z3/d2DRmdYL6hfwHHBZio15ILCCrvvH7gHSveWnPud0XWN/jvc83VvP/M7ex3GO9MrqEuBFwJJ5vN3GXQ8UnrYsZp/vhN8D58w3Tx7hU5Z4KHbONXrPdwHF3vOk+nPw/pk8DVhGCozZm06oBZqAxcBmYL9zrt1bpfvYTo3be/8AEI5v4oj9FPgXoNN7HSa5x3uSA/5sZjXeDd0hhp/vmN/UWPrPOefMLOmO8zSzXOBp4GvOuYNmduq9ZB2zc64DqDCzPOBZYLzPkWLGzP4OaHLO1ZjZxX7nibOPOOd2mNlQYLGZre/+ZrQ/30HYA0+1myfvNrPhAN5jk7c8Kf4czCyDrvJ+3Dn3jLc4qcfcnXNuP/AqXVMIeWZ2cieq+9hOjdt7fwjQEueokbgQ+LiZ1QNP0DWNci/JO95TnHM7vMcmuv6inkkMP99BKPBUu3ny88B13vPr6JonPrn8895vrmcDB7r9sywQrGtX+0FgnXPuJ93eStoxA5hZkbfnjZkNoGvefx1dRX6tt9rp4z7553Et8FfnTZIGgXPuW865kc65Mrr+f/2rc+4zJOl4TzKzHDMbdPI5cDmwmlh+vv2e9O/lLwauADbQNW94h995ojiu3wKNQBtd81830DX39wqwEfgLUOCta3QdjbMZWAVU+Z2/H+P9CF1zhCuBWu/rimQeszeOKcC73rhXA//LW14OvANsAp4Csrzl2d7rTd775X6PIYKxXwy8mArj9cZX532tOdlVsfx861R6EZGACsIUioiInIEKXEQkoFTgIiIBpQIXEQkoFbiISECpwEVEAkoFLiISUP8Pty1zP94123cAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"tags": [],
"needs_background": "light"
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "R8mI2uMtHzVI",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 0
},
"outputId": "706354cb-69f8-4672-debe-335552a3026e"
},
"source": [
"model.predict(x)"
],
"execution_count": 55,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[5.0000005]], dtype=float32)"
]
},
"metadata": {
"tags": []
},
"execution_count": 55
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "SbbRBFy9IGOy"
},
"source": [
"**2019-2021 [FinanceData.KR](http://financedata.kr) | [facebook.com/financedata](http://facebook.com/financedata)**"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment