Character Recurrent Neural Network

  • ¼ÎÀͽºÇÇ¾î ¹®Ã¼¸¦ ¸ð¹æÇÏ´Â ¼øȯ½Å°æ¸Á ½Ç½À ÄÚµåÀÔ´Ï´Ù.
  • Embedding ·¹ÀÌ¾î ¹× RNN ¸ðµ¨·Î ±¸¼ºµÇ¾î ÀÖ½À´Ï´Ù.

데이터를 먼저 준비해줍니다.

In [0]:
!rm -r data
import os 

try:
  os.mkdir("./data")
except:
  pass

!wget https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/tinyshakespeare/input.txt -P ./data
rm: cannot remove 'data': No such file or directory
--2019-06-03 09:24:43--  https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/tinyshakespeare/input.txt
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1115394 (1.1M) [text/plain]
Saving to: ¡®./data/input.txt¡¯

input.txt           100%[===================>]   1.06M  --.-KB/s    in 0.08s   

2019-06-03 09:24:49 (14.0 MB/s) - ¡®./data/input.txt¡¯ saved [1115394/1115394]

1. Settings

1) 필요한 라이브러리들을 불러옵니다

In [0]:
import torch
import torch.nn as nn
In [0]:
!pip install unidecode
Collecting unidecode
  Downloading https://files.pythonhosted.org/packages/31/39/53096f9217b057cb049fe872b7fc7ce799a1a89b76cf917d9639e7a558b5/Unidecode-1.0.23-py2.py3-none-any.whl (237kB)
     |