{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# RNN을 이용한 창작 (작곡) - 2\n",
"- https://tykimos.github.io/2017/04/09/RNN_Layer_Talk/"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 0. 코딩환경준비"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"conda create -n tf20 python==3.7
\n",
"conda activate tf20
\n",
"pip install jupyter
\n",
"pip install matplotlib
\n",
"pip install scipy
\n",
"pip install music21
\n",
"pip install tensorflow==2.0.0-alpha0"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- Musescore2 다운로드 및 설치 \n",
" - https://musescore.org/ko/download#older-versions"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2.0.0-alpha0\n"
]
}
],
"source": [
"import tensorflow as tf\n",
"print(tf.__version__)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import tensorflow.keras as keras\n",
"import numpy as np\n",
"from tensorflow.keras.models import Sequential\n",
"from tensorflow.keras.layers import Dense, LSTM\n",
"import tensorflow.keras.utils as utils\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"#http://web.mit.edu/music21/doc/usersGuide/usersGuide_08_installingMusicXML.html\n",
"import music21"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. 데이터 준비하기"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 시퀀스 데이터 정의"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"length of seq: 54\n"
]
}
],
"source": [
"seq = ['g8', 'e8', 'e4', 'f8', 'd8', 'd4', 'c8', 'd8', 'e8', 'f8', 'g8', 'g8', 'g4',\n",
" 'g8', 'e8', 'e8', 'e8', 'f8', 'd8', 'd4', 'c8', 'e8', 'g8', 'g8', 'e8', 'e8', 'e4',\n",
" 'd8', 'd8', 'd8', 'd8', 'd8', 'e8', 'f4', 'e8', 'e8', 'e8', 'e8', 'e8', 'f8', 'g4',\n",
" 'g8', 'e8', 'e4', 'f8', 'd8', 'd4', 'c8', 'e8', 'g8', 'g8', 'e8', 'e8', 'e4']\n",
"\n",
"print(\"length of seq: {0}\".format(len(seq)))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"