In [1]:
import tensorflow as tf
import numpy as np
tf.set_random_seed(777) # reproducibility
In [2]:
idx2char = ['h', 'i', 'e', 'l', 'o']
In [3]:
idx2char
Out[3]:
In [4]:
x_data = [[0, 1, 0, 2, 3, 3]] # hihell
In [5]:
x_one_hot = [[[1, 0, 0, 0, 0], # h 0
[0, 1, 0, 0, 0], # i 1
[1, 0, 0, 0, 0], # h 0
[0, 0, 1, 0, 0], # e 2
[0, 0, 0, 1, 0], # l 3
[0, 0, 0, 1, 0]]] # l 3
In [6]:
y_data = [[1, 0, 2, 3, 3, 4]] # ihello
In [7]:
num_classes = 5
input_dim = 5 # one-hot size
hidden_size = 5 # output from the LSTM. 5 to directly predict one-hot
batch_size = 1 # one sentence
sequence_length = 6 # |ihello| == 6
learning_rate = 0.1
In [ ]: