In [1]:
# Lab 12 Character Sequence RNN
import torch
import torch.nn as nn
from torch.autograd import Variable
torch.manual_seed(777) # reproducibility
sentence = ("if you want to build a ship, don't drum up people together to "
"collect wood and don't assign them tasks and work, but rather "
"teach them to long for the endless immensity of the sea.")
char_set = list(set(sentence))
char_dic = {w: i for i, w in enumerate(char_set)}
In [25]:
char_dic
Out[25]:
{' ': 20,
"'": 7,
',': 18,
'.': 23,
'a': 24,
'b': 0,
'c': 2,
'd': 9,
'e': 22,
'f': 17,
'g': 4,
'h': 5,
'i': 6,
'k': 13,
'l': 19,
'm': 16,
'n': 11,
'o': 10,
'p': 3,
'r': 8,
's': 12,
't': 21,
'u': 1,
'w': 14,
'y': 15}
In [2]:
# hyperparameters
learning_rate = 0.1
num_epochs = 500
input_size = len(char_set) # RNN input size (one hot size)
hidden_size = len(char_set) # RNN output size
num_classes = len(char_set) # final output size (RNN or softmax, etc.)
sequence_length = 10 # any arbitrary number
num_layers = 2 # number of layers in RNN
dataX = []
dataY = []
for i in range(0, len(sentence) - sequence_length):
x_str = sentence[i:i + sequence_length]
y_str = sentence[i + 1: i + sequence_length + 1]
print(i, x_str, '->', y_str)
x = [char_dic[c] for c in x_str] # x str to index
y = [char_dic[c] for c in y_str] # y str to index
dataX.append(x)
dataY.append(y)
batch_size = len(dataX)
x_data = torch.Tensor(dataX)
y_data = torch.LongTensor(dataY)
0 if you wan -> f you want
1 f you want -> you want
2 you want -> you want t
3 you want t -> ou want to
4 ou want to -> u want to
5 u want to -> want to b
6 want to b -> want to bu
7 want to bu -> ant to bui
8 ant to bui -> nt to buil
9 nt to buil -> t to build
10 t to build -> to build
11 to build -> to build a
12 to build a -> o build a
13 o build a -> build a s
14 build a s -> build a sh
15 build a sh -> uild a shi
16 uild a shi -> ild a ship
17 ild a ship -> ld a ship,
18 ld a ship, -> d a ship,
19 d a ship, -> a ship, d
20 a ship, d -> a ship, do
21 a ship, do -> ship, don
22 ship, don -> ship, don'
23 ship, don' -> hip, don't
24 hip, don't -> ip, don't
25 ip, don't -> p, don't d
26 p, don't d -> , don't dr
27 , don't dr -> don't dru
28 don't dru -> don't drum
29 don't drum -> on't drum
30 on't drum -> n't drum u
31 n't drum u -> 't drum up
32 't drum up -> t drum up
33 t drum up -> drum up p
34 drum up p -> drum up pe
35 drum up pe -> rum up peo
36 rum up peo -> um up peop
37 um up peop -> m up peopl
38 m up peopl -> up people
39 up people -> up people
40 up people -> p people t
41 p people t -> people to
42 people to -> people tog
43 people tog -> eople toge
44 eople toge -> ople toget
45 ople toget -> ple togeth
46 ple togeth -> le togethe
47 le togethe -> e together
48 e together -> together
49 together -> together t
50 together t -> ogether to
51 ogether to -> gether to
52 gether to -> ether to c
53 ether to c -> ther to co
54 ther to co -> her to col
55 her to col -> er to coll
56 er to coll -> r to colle
57 r to colle -> to collec
58 to collec -> to collect
59 to collect -> o collect
60 o collect -> collect w
61 collect w -> collect wo
62 collect wo -> ollect woo
63 ollect woo -> llect wood
64 llect wood -> lect wood
65 lect wood -> ect wood a
66 ect wood a -> ct wood an
67 ct wood an -> t wood and
68 t wood and -> wood and
69 wood and -> wood and d
70 wood and d -> ood and do
71 ood and do -> od and don
72 od and don -> d and don'
73 d and don' -> and don't
74 and don't -> and don't
75 and don't -> nd don't a
76 nd don't a -> d don't as
77 d don't as -> don't ass
78 don't ass -> don't assi
79 don't assi -> on't assig
80 on't assig -> n't assign
81 n't assign -> 't assign
82 't assign -> t assign t
83 t assign t -> assign th
84 assign th -> assign the
85 assign the -> ssign them
86 ssign them -> sign them
87 sign them -> ign them t
88 ign them t -> gn them ta
89 gn them ta -> n them tas
90 n them tas -> them task
91 them task -> them tasks
92 them tasks -> hem tasks
93 hem tasks -> em tasks a
94 em tasks a -> m tasks an
95 m tasks an -> tasks and
96 tasks and -> tasks and
97 tasks and -> asks and w
98 asks and w -> sks and wo
99 sks and wo -> ks and wor
100 ks and wor -> s and work
101 s and work -> and work,
102 and work, -> and work,
103 and work, -> nd work, b
104 nd work, b -> d work, bu
105 d work, bu -> work, but
106 work, but -> work, but
107 work, but -> ork, but r
108 ork, but r -> rk, but ra
109 rk, but ra -> k, but rat
110 k, but rat -> , but rath
111 , but rath -> but rathe
112 but rathe -> but rather
113 but rather -> ut rather
114 ut rather -> t rather t
115 t rather t -> rather te
116 rather te -> rather tea
117 rather tea -> ather teac
118 ather teac -> ther teach
119 ther teach -> her teach
120 her teach -> er teach t
121 er teach t -> r teach th
122 r teach th -> teach the
123 teach the -> teach them
124 teach them -> each them
125 each them -> ach them t
126 ach them t -> ch them to
127 ch them to -> h them to
128 h them to -> them to l
129 them to l -> them to lo
130 them to lo -> hem to lon
131 hem to lon -> em to long
132 em to long -> m to long
133 m to long -> to long f
134 to long f -> to long fo
135 to long fo -> o long for
136 o long for -> long for
137 long for -> long for t
138 long for t -> ong for th
139 ong for th -> ng for the
140 ng for the -> g for the
141 g for the -> for the e
142 for the e -> for the en
143 for the en -> or the end
144 or the end -> r the endl
145 r the endl -> the endle
146 the endle -> the endles
147 the endles -> he endless
148 he endless -> e endless
149 e endless -> endless i
150 endless i -> endless im
151 endless im -> ndless imm
152 ndless imm -> dless imme
153 dless imme -> less immen
154 less immen -> ess immens
155 ess immens -> ss immensi
156 ss immensi -> s immensit
157 s immensit -> immensity
158 immensity -> immensity
159 immensity -> mmensity o
160 mmensity o -> mensity of
161 mensity of -> ensity of
162 ensity of -> nsity of t
163 nsity of t -> sity of th
164 sity of th -> ity of the
165 ity of the -> ty of the
166 ty of the -> y of the s
167 y of the s -> of the se
168 of the se -> of the sea
169 of the sea -> f the sea.
In [3]:
# one hot encoding
def one_hot(x, num_classes):
idx = x.long()
idx = idx.view(-1, 1)
x_one_hot = torch.zeros(x.size()[0] * x.size()[1], num_classes)
x_one_hot.scatter_(1, idx, 1)
x_one_hot = x_one_hot.view(x.size()[0], x.size()[1], num_classes)
return x_one_hot
x_one_hot = one_hot(x_data, num_classes)
inputs = Variable(x_one_hot)
labels = Variable(y_data)
In [4]:
x_one_hot
Out[4]:
( 0 ,.,.) =
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
... ⋱ ...
0 0 0 ... 0 0 0
1 0 0 ... 0 0 0
0 0 0 ... 0 0 0
( 1 ,.,.) =
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
... ⋱ ...
1 0 0 ... 0 0 0
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
( 2 ,.,.) =
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
... ⋱ ...
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
...
(167,.,.) =
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
... ⋱ ...
0 0 0 ... 0 0 1
0 0 0 ... 0 0 0
0 0 0 ... 1 0 0
(168,.,.) =
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
... ⋱ ...
0 0 0 ... 0 0 0
0 0 0 ... 1 0 0
0 0 0 ... 0 0 1
(169,.,.) =
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
0 0 0 ... 0 0 0
... ⋱ ...
0 0 0 ... 1 0 0
0 0 0 ... 0 0 1
1 0 0 ... 0 0 0
[torch.FloatTensor of size 170x10x25]
In [5]:
class LSTM(nn.Module):
def __init__(self, num_classes, input_size, hidden_size, num_layers):
super(LSTM, self).__init__()
self.num_classes = num_classes
self.num_layers = num_layers
self.input_size = input_size
self.hidden_size = hidden_size
self.sequence_length = sequence_length
# Set parameters for RNN block
# Note: batch_first=False by default.
# When true, inputs are (batch_size, sequence_length, input_dimension)
# instead of (sequence_length, batch_size, input_dimension)
self.lstm = nn.LSTM(input_size=input_size, hidden_size=hidden_size,
num_layers=num_layers,batch_first=True)
# Fully connected layer
self.fc = nn.Linear(hidden_size, num_classes)
def forward(self, x):
# Initialize hidden and cell states
h_0 = Variable(torch.zeros(
self.num_layers, x.size(0), self.hidden_size))
c_0 = Variable(torch.zeros(
self.num_layers, x.size(0), self.hidden_size))
# h_0 = Variable(torch.zeros(
# self.num_layers, x.size(0), self.hidden_size))
# c_0 = Variable(torch.zeros(
# self.num_layers, x.size(0), self.hidden_size))
# Propagate input through LSTM
# Input: (batch, seq_len, input_size)
out, _ = self.lstm(x, (h_0, c_0))
# Note: the output tensor of LSTM in this case is a block with holes
# > add .contiguous() to apply view()
out = out.contiguous().view(-1, self.hidden_size)
# Return outputs applied to fully connected layer
out = self.fc(out)
return out
In [6]:
# Instantiate RNN model
lstm = LSTM(num_classes, input_size, hidden_size, num_layers)
# Set loss and optimizer function
criterion = torch.nn.CrossEntropyLoss() # Softmax is internally computed.
optimizer = torch.optim.Adam(lstm.parameters(), lr=learning_rate)
In [7]:
# Train the model
for epoch in range(num_epochs):
outputs = lstm(inputs)
optimizer.zero_grad()
# obtain the loss function
# flatten target labels to match output
loss = criterion(outputs, labels.view(-1))
loss.backward()
optimizer.step()
# obtain the predicted indices of the next character
_, idx = outputs.max(1)
idx = idx.data.numpy()
idx = idx.reshape(-1, sequence_length) # (170,10)
# display the prediction of the last sequence
result_str = [char_set[c] for c in idx[-2]]
print("epoch: %d, loss: %1.3f" % (epoch + 1, loss.data[0]))
print("Predicted string: ", ''.join(result_str))
print("Learning finished!")
epoch: 1, loss: 3.241
Predicted string: ..........
epoch: 2, loss: 3.006
Predicted string: ddddddddss
epoch: 3, loss: 2.926
Predicted string: e
epoch: 4, loss: 2.965
Predicted string:
epoch: 5, loss: 2.853
Predicted string:
epoch: 6, loss: 2.849
Predicted string:
epoch: 7, loss: 2.837
Predicted string:
epoch: 8, loss: 2.815
Predicted string:
epoch: 9, loss: 2.791
Predicted string:
epoch: 10, loss: 2.759
Predicted string: o oo o
epoch: 11, loss: 2.708
Predicted string: oo oo o
epoch: 12, loss: 2.635
Predicted string: oo oo o
epoch: 13, loss: 2.569
Predicted string: oo oo o
epoch: 14, loss: 2.504
Predicted string: oo oo o
epoch: 15, loss: 2.438
Predicted string: oo oo oo
epoch: 16, loss: 2.361
Predicted string: on oo o
epoch: 17, loss: 2.249
Predicted string: on oo tnn
epoch: 18, loss: 2.176
Predicted string: on oerann
epoch: 19, loss: 2.135
Predicted string: en oe tnm
epoch: 20, loss: 2.068
Predicted string: tn oertos
epoch: 21, loss: 1.966
Predicted string: tn toe tos
epoch: 22, loss: 1.875
Predicted string: tn toe tos
epoch: 23, loss: 1.784
Predicted string: hn toe tor
epoch: 24, loss: 1.700
Predicted string: hn toertor
epoch: 25, loss: 1.595
Predicted string: tn toe tor
epoch: 26, loss: 1.500
Predicted string: tn toerton
epoch: 27, loss: 1.406
Predicted string: tn toerton
epoch: 28, loss: 1.314
Predicted string: tn toemton
epoch: 29, loss: 1.225
Predicted string: tn themtor
epoch: 30, loss: 1.154
Predicted string: tn themtor
epoch: 31, loss: 1.084
Predicted string: tn thertor
epoch: 32, loss: 1.012
Predicted string: tn thertor
epoch: 33, loss: 0.947
Predicted string: tn therwor
epoch: 34, loss: 0.885
Predicted string: tn thertor
epoch: 35, loss: 0.818
Predicted string: tn themtoa
epoch: 36, loss: 0.765
Predicted string: tn themtoa
epoch: 37, loss: 0.723
Predicted string: tn the taa
epoch: 38, loss: 0.678
Predicted string: tn the eaa
epoch: 39, loss: 0.628
Predicted string: tn the tea
epoch: 40, loss: 0.586
Predicted string: tn the tea
epoch: 41, loss: 0.552
Predicted string: tn the taa
epoch: 42, loss: 0.524
Predicted string: tn the tea
epoch: 43, loss: 0.497
Predicted string: tn the taa
epoch: 44, loss: 0.480
Predicted string: tn thee ea
epoch: 45, loss: 0.478
Predicted string: dn the taa
epoch: 46, loss: 0.447
Predicted string: tn the tea
epoch: 47, loss: 0.427
Predicted string: dn the tea
epoch: 48, loss: 0.410
Predicted string: dn the tea
epoch: 49, loss: 0.394
Predicted string: dn the tea
epoch: 50, loss: 0.382
Predicted string: tf therfea
epoch: 51, loss: 0.366
Predicted string: tf the tea
epoch: 52, loss: 0.350
Predicted string: tf the tea
epoch: 53, loss: 0.344
Predicted string: tf the sea
epoch: 54, loss: 0.338
Predicted string: tf the sea
epoch: 55, loss: 0.325
Predicted string: tf the sea
epoch: 56, loss: 0.319
Predicted string: tf the sea
epoch: 57, loss: 0.313
Predicted string: tf the sea
epoch: 58, loss: 0.310
Predicted string: tf the sea
epoch: 59, loss: 0.300
Predicted string: tf the sea
epoch: 60, loss: 0.299
Predicted string: tf the sea
epoch: 61, loss: 0.297
Predicted string: tf the sea
epoch: 62, loss: 0.291
Predicted string: tf the sea
epoch: 63, loss: 0.285
Predicted string: tf the sea
epoch: 64, loss: 0.282
Predicted string: tf the sea
epoch: 65, loss: 0.279
Predicted string: tf the sea
epoch: 66, loss: 0.275
Predicted string: tf the sea
epoch: 67, loss: 0.271
Predicted string: tf the sea
epoch: 68, loss: 0.269
Predicted string: tf the sea
epoch: 69, loss: 0.266
Predicted string: tf the sea
epoch: 70, loss: 0.264
Predicted string: tf the sea
epoch: 71, loss: 0.264
Predicted string: tf the sea
epoch: 72, loss: 0.262
Predicted string: tf the sea
epoch: 73, loss: 0.259
Predicted string: tf the sea
epoch: 74, loss: 0.258
Predicted string: tf the sea
epoch: 75, loss: 0.256
Predicted string: tf the sea
epoch: 76, loss: 0.254
Predicted string: tf the sea
epoch: 77, loss: 0.253
Predicted string: tf the sea
epoch: 78, loss: 0.252
Predicted string: tf the sea
epoch: 79, loss: 0.250
Predicted string: tf the sea
epoch: 80, loss: 0.249
Predicted string: tf the sea
epoch: 81, loss: 0.248
Predicted string: tf the sea
epoch: 82, loss: 0.247
Predicted string: tf the sea
epoch: 83, loss: 0.245
Predicted string: tf the sea
epoch: 84, loss: 0.245
Predicted string: tf the sea
epoch: 85, loss: 0.244
Predicted string: tf the sea
epoch: 86, loss: 0.246
Predicted string: tf the sea
epoch: 87, loss: 0.244
Predicted string: tf the sea
epoch: 88, loss: 0.242
Predicted string: tf the sea
epoch: 89, loss: 0.242
Predicted string: tf the sea
epoch: 90, loss: 0.241
Predicted string: tf the sea
epoch: 91, loss: 0.241
Predicted string: tf the sea
epoch: 92, loss: 0.240
Predicted string: tf the sea
epoch: 93, loss: 0.240
Predicted string: tf the sea
epoch: 94, loss: 0.239
Predicted string: tf the sea
epoch: 95, loss: 0.239
Predicted string: tf the sea
epoch: 96, loss: 0.238
Predicted string: tf the sea
epoch: 97, loss: 0.238
Predicted string: tf the sea
epoch: 98, loss: 0.238
Predicted string: tf the sea
epoch: 99, loss: 0.238
Predicted string: tf the sea
epoch: 100, loss: 0.237
Predicted string: tf the sea
epoch: 101, loss: 0.237
Predicted string: tf the sea
epoch: 102, loss: 0.237
Predicted string: tf the sea
epoch: 103, loss: 0.237
Predicted string: tf the sea
epoch: 104, loss: 0.237
Predicted string: tf the sea
epoch: 105, loss: 0.236
Predicted string: tf the sea
epoch: 106, loss: 0.236
Predicted string: tf the sea
epoch: 107, loss: 0.236
Predicted string: tf the sea
epoch: 108, loss: 0.236
Predicted string: tf the sea
epoch: 109, loss: 0.235
Predicted string: tf the sea
epoch: 110, loss: 0.235
Predicted string: tf the sea
epoch: 111, loss: 0.235
Predicted string: tf the sea
epoch: 112, loss: 0.235
Predicted string: tf the sea
epoch: 113, loss: 0.235
Predicted string: tf the sea
epoch: 114, loss: 0.235
Predicted string: tf the sea
epoch: 115, loss: 0.235
Predicted string: tf the sea
epoch: 116, loss: 0.235
Predicted string: tf the sea
epoch: 117, loss: 0.234
Predicted string: tf the sea
epoch: 118, loss: 0.234
Predicted string: tf the sea
epoch: 119, loss: 0.234
Predicted string: tf the sea
epoch: 120, loss: 0.234
Predicted string: tf the sea
epoch: 121, loss: 0.234
Predicted string: tf the sea
epoch: 122, loss: 0.234
Predicted string: tf the sea
epoch: 123, loss: 0.234
Predicted string: tf the sea
epoch: 124, loss: 0.234
Predicted string: tf the sea
epoch: 125, loss: 0.234
Predicted string: tf the sea
epoch: 126, loss: 0.235
Predicted string: tf the sea
epoch: 127, loss: 0.234
Predicted string: tf the sea
epoch: 128, loss: 0.234
Predicted string: tf the sea
epoch: 129, loss: 0.233
Predicted string: tf the sea
epoch: 130, loss: 0.233
Predicted string: tf the sea
epoch: 131, loss: 0.233
Predicted string: tf the sea
epoch: 132, loss: 0.233
Predicted string: tf the sea
epoch: 133, loss: 0.233
Predicted string: tf the sea
epoch: 134, loss: 0.233
Predicted string: tf the sea
epoch: 135, loss: 0.233
Predicted string: tf the sea
epoch: 136, loss: 0.233
Predicted string: tf the sea
epoch: 137, loss: 0.233
Predicted string: tf the sea
epoch: 138, loss: 0.233
Predicted string: tf the sea
epoch: 139, loss: 0.233
Predicted string: tf the sea
epoch: 140, loss: 0.233
Predicted string: tf the sea
epoch: 141, loss: 0.232
Predicted string: tf the sea
epoch: 142, loss: 0.232
Predicted string: tf the sea
epoch: 143, loss: 0.232
Predicted string: tf the sea
epoch: 144, loss: 0.232
Predicted string: tf the sea
epoch: 145, loss: 0.232
Predicted string: tf the sea
epoch: 146, loss: 0.232
Predicted string: tf the sea
epoch: 147, loss: 0.232
Predicted string: tf the sea
epoch: 148, loss: 0.232
Predicted string: tf the sea
epoch: 149, loss: 0.232
Predicted string: tf the sea
epoch: 150, loss: 0.232
Predicted string: tf the sea
epoch: 151, loss: 0.232
Predicted string: tf the sea
epoch: 152, loss: 0.232
Predicted string: tf the sea
epoch: 153, loss: 0.232
Predicted string: tf the sea
epoch: 154, loss: 0.232
Predicted string: tf the sea
epoch: 155, loss: 0.232
Predicted string: tf the sea
epoch: 156, loss: 0.232
Predicted string: tf the sea
epoch: 157, loss: 0.232
Predicted string: tf the sea
epoch: 158, loss: 0.232
Predicted string: tf the sea
epoch: 159, loss: 0.232
Predicted string: tf the sea
epoch: 160, loss: 0.232
Predicted string: tf the sea
epoch: 161, loss: 0.232
Predicted string: tf the sea
epoch: 162, loss: 0.232
Predicted string: tf the sea
epoch: 163, loss: 0.232
Predicted string: tf the sea
epoch: 164, loss: 0.232
Predicted string: tf the sea
epoch: 165, loss: 0.233
Predicted string: tf the sea
epoch: 166, loss: 0.234
Predicted string: tf the sea
epoch: 167, loss: 0.232
Predicted string: tf the sea
epoch: 168, loss: 0.232
Predicted string: tf the sea
epoch: 169, loss: 0.232
Predicted string: tf the sea
epoch: 170, loss: 0.232
Predicted string: tf the sea
epoch: 171, loss: 0.232
Predicted string: tf the sea
epoch: 172, loss: 0.232
Predicted string: tf the sea
epoch: 173, loss: 0.232
Predicted string: tf the sea
epoch: 174, loss: 0.232
Predicted string: tf the sea
epoch: 175, loss: 0.232
Predicted string: tf the sea
epoch: 176, loss: 0.232
Predicted string: tf the sea
epoch: 177, loss: 0.232
Predicted string: tf the sea
epoch: 178, loss: 0.232
Predicted string: tf the sea
epoch: 179, loss: 0.232
Predicted string: tf the sea
epoch: 180, loss: 0.231
Predicted string: tf the sea
epoch: 181, loss: 0.231
Predicted string: tf the sea
epoch: 182, loss: 0.231
Predicted string: tf the sea
epoch: 183, loss: 0.231
Predicted string: tf the sea
epoch: 184, loss: 0.231
Predicted string: tf the sea
epoch: 185, loss: 0.231
Predicted string: tf the sea
epoch: 186, loss: 0.231
Predicted string: tf the sea
epoch: 187, loss: 0.231
Predicted string: tf the sea
epoch: 188, loss: 0.231
Predicted string: tf the sea
epoch: 189, loss: 0.231
Predicted string: tf the sea
epoch: 190, loss: 0.231
Predicted string: tf the sea
epoch: 191, loss: 0.231
Predicted string: tf the sea
epoch: 192, loss: 0.231
Predicted string: tf the sea
epoch: 193, loss: 0.231
Predicted string: tf the sea
epoch: 194, loss: 0.231
Predicted string: tf the sea
epoch: 195, loss: 0.231
Predicted string: tf the sea
epoch: 196, loss: 0.231
Predicted string: tf the sea
epoch: 197, loss: 0.231
Predicted string: tf the sea
epoch: 198, loss: 0.231
Predicted string: tf the sea
epoch: 199, loss: 0.231
Predicted string: tf the sea
epoch: 200, loss: 0.231
Predicted string: tf the sea
epoch: 201, loss: 0.231
Predicted string: tf the sea
epoch: 202, loss: 0.231
Predicted string: tf the sea
epoch: 203, loss: 0.231
Predicted string: tf the sea
epoch: 204, loss: 0.231
Predicted string: tf the sea
epoch: 205, loss: 0.231
Predicted string: tf the sea
epoch: 206, loss: 0.231
Predicted string: tf the sea
epoch: 207, loss: 0.231
Predicted string: tf the sea
epoch: 208, loss: 0.231
Predicted string: tf the sea
epoch: 209, loss: 0.232
Predicted string: tf the sea
epoch: 210, loss: 0.232
Predicted string: tf the sea
epoch: 211, loss: 0.232
Predicted string: tf the sea
epoch: 212, loss: 0.231
Predicted string: tf the sea
epoch: 213, loss: 0.231
Predicted string: tf the sea
epoch: 214, loss: 0.231
Predicted string: tf the sea
epoch: 215, loss: 0.231
Predicted string: tf the sea
epoch: 216, loss: 0.231
Predicted string: tf the sea
epoch: 217, loss: 0.231
Predicted string: tf the sea
epoch: 218, loss: 0.231
Predicted string: tf the sea
epoch: 219, loss: 0.231
Predicted string: tf the sea
epoch: 220, loss: 0.231
Predicted string: tf the sea
epoch: 221, loss: 0.230
Predicted string: tf the sea
epoch: 222, loss: 0.230
Predicted string: tf the sea
epoch: 223, loss: 0.230
Predicted string: tf the sea
epoch: 224, loss: 0.230
Predicted string: tf the sea
epoch: 225, loss: 0.230
Predicted string: tf the sea
epoch: 226, loss: 0.230
Predicted string: tf the sea
epoch: 227, loss: 0.230
Predicted string: tf the sea
epoch: 228, loss: 0.230
Predicted string: tf the sea
epoch: 229, loss: 0.230
Predicted string: tf the sea
epoch: 230, loss: 0.230
Predicted string: tf the sea
epoch: 231, loss: 0.230
Predicted string: tf the sea
epoch: 232, loss: 0.230
Predicted string: tf the sea
epoch: 233, loss: 0.230
Predicted string: tf the sea
epoch: 234, loss: 0.230
Predicted string: tf the sea
epoch: 235, loss: 0.230
Predicted string: tf the sea
epoch: 236, loss: 0.230
Predicted string: tf the sea
epoch: 237, loss: 0.230
Predicted string: tf the sea
epoch: 238, loss: 0.230
Predicted string: tf the sea
epoch: 239, loss: 0.230
Predicted string: tf the sea
epoch: 240, loss: 0.230
Predicted string: tf the sea
epoch: 241, loss: 0.231
Predicted string: tf the sea
epoch: 242, loss: 0.231
Predicted string: tf the sea
epoch: 243, loss: 0.230
Predicted string: tf the sea
epoch: 244, loss: 0.230
Predicted string: tf the sea
epoch: 245, loss: 0.230
Predicted string: tf the sea
epoch: 246, loss: 0.230
Predicted string: tf the sea
epoch: 247, loss: 0.231
Predicted string: tf the sea
epoch: 248, loss: 0.231
Predicted string: tf the sea
epoch: 249, loss: 0.231
Predicted string: tf the sea
epoch: 250, loss: 0.231
Predicted string: tf the sea
epoch: 251, loss: 0.230
Predicted string: tf the sea
epoch: 252, loss: 0.230
Predicted string: tf the sea
epoch: 253, loss: 0.230
Predicted string: tf the sea
epoch: 254, loss: 0.230
Predicted string: tf the sea
epoch: 255, loss: 0.230
Predicted string: tf the sea
epoch: 256, loss: 0.230
Predicted string: tf the sea
epoch: 257, loss: 0.230
Predicted string: tf the sea
epoch: 258, loss: 0.230
Predicted string: tf the sea
epoch: 259, loss: 0.230
Predicted string: tf the sea
epoch: 260, loss: 0.230
Predicted string: tf the sea
epoch: 261, loss: 0.230
Predicted string: tf the sea
epoch: 262, loss: 0.230
Predicted string: tf the sea
epoch: 263, loss: 0.230
Predicted string: tf the sea
epoch: 264, loss: 0.230
Predicted string: tf the sea
epoch: 265, loss: 0.230
Predicted string: tf the sea
epoch: 266, loss: 0.230
Predicted string: tf the sea
epoch: 267, loss: 0.230
Predicted string: tf the sea
epoch: 268, loss: 0.230
Predicted string: tf the sea
epoch: 269, loss: 0.230
Predicted string: tf the sea
epoch: 270, loss: 0.230
Predicted string: tf the sea
epoch: 271, loss: 0.230
Predicted string: tf the sea
epoch: 272, loss: 0.230
Predicted string: tf the sea
epoch: 273, loss: 0.230
Predicted string: tf the sea
epoch: 274, loss: 0.230
Predicted string: tf the sea
epoch: 275, loss: 0.230
Predicted string: tf the sea
epoch: 276, loss: 0.230
Predicted string: tf the sea
epoch: 277, loss: 0.230
Predicted string: tf the sea
epoch: 278, loss: 0.230
Predicted string: tf the sea
epoch: 279, loss: 0.230
Predicted string: tf the sea
epoch: 280, loss: 0.230
Predicted string: tf the sea
epoch: 281, loss: 0.230
Predicted string: tf the sea
epoch: 282, loss: 0.230
Predicted string: tf the sea
epoch: 283, loss: 0.230
Predicted string: tf the sea
epoch: 284, loss: 0.230
Predicted string: tf the sea
epoch: 285, loss: 0.230
Predicted string: tf the sea
epoch: 286, loss: 0.230
Predicted string: tf the sea
epoch: 287, loss: 0.230
Predicted string: tf the sea
epoch: 288, loss: 0.230
Predicted string: tf the sea
epoch: 289, loss: 0.230
Predicted string: tf the sea
epoch: 290, loss: 0.230
Predicted string: tf the sea
epoch: 291, loss: 0.231
Predicted string: tf the sea
epoch: 292, loss: 0.231
Predicted string: tf the sea
epoch: 293, loss: 0.231
Predicted string: tf the sea
epoch: 294, loss: 0.231
Predicted string: tf the sea
epoch: 295, loss: 0.231
Predicted string: tf the sea
epoch: 296, loss: 0.230
Predicted string: tf the sea
epoch: 297, loss: 0.231
Predicted string: tf the sea
epoch: 298, loss: 0.231
Predicted string: tf the sea
epoch: 299, loss: 0.230
Predicted string: tf the sea
epoch: 300, loss: 0.230
Predicted string: tf the sea
epoch: 301, loss: 0.230
Predicted string: tf the sea
epoch: 302, loss: 0.230
Predicted string: tf the sea
epoch: 303, loss: 0.230
Predicted string: tf the sea
epoch: 304, loss: 0.230
Predicted string: tf the sea
epoch: 305, loss: 0.230
Predicted string: tf the sea
epoch: 306, loss: 0.230
Predicted string: tf the sea
epoch: 307, loss: 0.230
Predicted string: tf the sea
epoch: 308, loss: 0.230
Predicted string: tf the sea
epoch: 309, loss: 0.230
Predicted string: tf the sea
epoch: 310, loss: 0.230
Predicted string: tf the sea
epoch: 311, loss: 0.230
Predicted string: tf the sea
epoch: 312, loss: 0.230
Predicted string: tf the sea
epoch: 313, loss: 0.230
Predicted string: tf the sea
epoch: 314, loss: 0.230
Predicted string: tf the sea
epoch: 315, loss: 0.230
Predicted string: tf the sea
epoch: 316, loss: 0.230
Predicted string: tf the sea
epoch: 317, loss: 0.230
Predicted string: tf the sea
epoch: 318, loss: 0.230
Predicted string: tf the sea
epoch: 319, loss: 0.230
Predicted string: tf the sea
epoch: 320, loss: 0.230
Predicted string: tf the sea
epoch: 321, loss: 0.230
Predicted string: tf the sea
epoch: 322, loss: 0.230
Predicted string: tf the sea
epoch: 323, loss: 0.230
Predicted string: tf the sea
epoch: 324, loss: 0.230
Predicted string: tf the sea
epoch: 325, loss: 0.230
Predicted string: tf the sea
epoch: 326, loss: 0.230
Predicted string: tf the sea
epoch: 327, loss: 0.230
Predicted string: tf the sea
epoch: 328, loss: 0.230
Predicted string: tf the sea
epoch: 329, loss: 0.230
Predicted string: tf the sea
epoch: 330, loss: 0.230
Predicted string: tf the sea
epoch: 331, loss: 0.229
Predicted string: tf the sea
epoch: 332, loss: 0.229
Predicted string: tf the sea
epoch: 333, loss: 0.229
Predicted string: tf the sea
epoch: 334, loss: 0.229
Predicted string: tf the sea
epoch: 335, loss: 0.229
Predicted string: tf the sea
epoch: 336, loss: 0.229
Predicted string: tf the sea
epoch: 337, loss: 0.229
Predicted string: tf the sea
epoch: 338, loss: 0.229
Predicted string: tf the sea
epoch: 339, loss: 0.229
Predicted string: tf the sea
epoch: 340, loss: 0.229
Predicted string: tf the sea
epoch: 341, loss: 0.229
Predicted string: tf the sea
epoch: 342, loss: 0.229
Predicted string: tf the sea
epoch: 343, loss: 0.229
Predicted string: tf the sea
epoch: 344, loss: 0.229
Predicted string: tf the sea
epoch: 345, loss: 0.229
Predicted string: tf the sea
epoch: 346, loss: 0.229
Predicted string: tf the sea
epoch: 347, loss: 0.230
Predicted string: tf the sea
epoch: 348, loss: 0.230
Predicted string: tf the sea
epoch: 349, loss: 0.230
Predicted string: tf the sea
epoch: 350, loss: 0.231
Predicted string: tf the sea
epoch: 351, loss: 0.231
Predicted string: tf the sea
epoch: 352, loss: 0.231
Predicted string: tf the sea
epoch: 353, loss: 0.230
Predicted string: tf the sea
epoch: 354, loss: 0.230
Predicted string: tf the sea
epoch: 355, loss: 0.229
Predicted string: tf the sea
epoch: 356, loss: 0.230
Predicted string: tf the sea
epoch: 357, loss: 0.230
Predicted string: tf the sea
epoch: 358, loss: 0.230
Predicted string: tf the sea
epoch: 359, loss: 0.230
Predicted string: tf the sea
epoch: 360, loss: 0.229
Predicted string: tf the sea
epoch: 361, loss: 0.229
Predicted string: tf the sea
epoch: 362, loss: 0.230
Predicted string: tf the sea
epoch: 363, loss: 0.230
Predicted string: tf the sea
epoch: 364, loss: 0.229
Predicted string: tf the sea
epoch: 365, loss: 0.229
Predicted string: tf the sea
epoch: 366, loss: 0.229
Predicted string: tf the sea
epoch: 367, loss: 0.229
Predicted string: tf the sea
epoch: 368, loss: 0.229
Predicted string: tf the sea
epoch: 369, loss: 0.229
Predicted string: tf the sea
epoch: 370, loss: 0.229
Predicted string: tf the sea
epoch: 371, loss: 0.229
Predicted string: tf the sea
epoch: 372, loss: 0.229
Predicted string: tf the sea
epoch: 373, loss: 0.229
Predicted string: tf the sea
epoch: 374, loss: 0.229
Predicted string: tf the sea
epoch: 375, loss: 0.229
Predicted string: tf the sea
epoch: 376, loss: 0.229
Predicted string: tf the sea
epoch: 377, loss: 0.229
Predicted string: tf the sea
epoch: 378, loss: 0.229
Predicted string: tf the sea
epoch: 379, loss: 0.229
Predicted string: tf the sea
epoch: 380, loss: 0.229
Predicted string: tf the sea
epoch: 381, loss: 0.229
Predicted string: tf the sea
epoch: 382, loss: 0.229
Predicted string: tf the sea
epoch: 383, loss: 0.229
Predicted string: tf the sea
epoch: 384, loss: 0.229
Predicted string: tf the sea
epoch: 385, loss: 0.229
Predicted string: tf the sea
epoch: 386, loss: 0.229
Predicted string: tf the sea
epoch: 387, loss: 0.229
Predicted string: tf the sea
epoch: 388, loss: 0.229
Predicted string: tf the sea
epoch: 389, loss: 0.229
Predicted string: tf the sea
epoch: 390, loss: 0.229
Predicted string: tf the sea
epoch: 391, loss: 0.229
Predicted string: tf the sea
epoch: 392, loss: 0.229
Predicted string: tf the sea
epoch: 393, loss: 0.229
Predicted string: tf the sea
epoch: 394, loss: 0.229
Predicted string: tf the sea
epoch: 395, loss: 0.230
Predicted string: tf the sea
epoch: 396, loss: 0.231
Predicted string: tf the sea
epoch: 397, loss: 0.232
Predicted string: tf the sea
epoch: 398, loss: 0.231
Predicted string: tf the sea
epoch: 399, loss: 0.230
Predicted string: tf the sea
epoch: 400, loss: 0.230
Predicted string: tf the sea
epoch: 401, loss: 0.230
Predicted string: tf the sea
epoch: 402, loss: 0.230
Predicted string: tf the sea
epoch: 403, loss: 0.229
Predicted string: tf the sea
epoch: 404, loss: 0.230
Predicted string: tf the sea
epoch: 405, loss: 0.230
Predicted string: tf the sea
epoch: 406, loss: 0.229
Predicted string: tf the sea
epoch: 407, loss: 0.230
Predicted string: tf the sea
epoch: 408, loss: 0.230
Predicted string: tf the sea
epoch: 409, loss: 0.229
Predicted string: tf the sea
epoch: 410, loss: 0.230
Predicted string: tf the sea
epoch: 411, loss: 0.230
Predicted string: tf the sea
epoch: 412, loss: 0.229
Predicted string: tf the sea
epoch: 413, loss: 0.229
Predicted string: tf the sea
epoch: 414, loss: 0.229
Predicted string: tf the sea
epoch: 415, loss: 0.229
Predicted string: tf the sea
epoch: 416, loss: 0.229
Predicted string: tf the sea
epoch: 417, loss: 0.229
Predicted string: tf the sea
epoch: 418, loss: 0.229
Predicted string: tf the sea
epoch: 419, loss: 0.229
Predicted string: tf the sea
epoch: 420, loss: 0.229
Predicted string: tf the sea
epoch: 421, loss: 0.229
Predicted string: tf the sea
epoch: 422, loss: 0.229
Predicted string: tf the sea
epoch: 423, loss: 0.229
Predicted string: tf the sea
epoch: 424, loss: 0.229
Predicted string: tf the sea
epoch: 425, loss: 0.229
Predicted string: tf the sea
epoch: 426, loss: 0.229
Predicted string: tf the sea
epoch: 427, loss: 0.229
Predicted string: tf the sea
epoch: 428, loss: 0.229
Predicted string: tf the sea
epoch: 429, loss: 0.229
Predicted string: tf the sea
epoch: 430, loss: 0.229
Predicted string: tf the sea
epoch: 431, loss: 0.229
Predicted string: tf the sea
epoch: 432, loss: 0.229
Predicted string: tf the sea
epoch: 433, loss: 0.229
Predicted string: tf the sea
epoch: 434, loss: 0.229
Predicted string: tf the sea
epoch: 435, loss: 0.229
Predicted string: tf the sea
epoch: 436, loss: 0.229
Predicted string: tf the sea
epoch: 437, loss: 0.229
Predicted string: tf the sea
epoch: 438, loss: 0.229
Predicted string: tf the sea
epoch: 439, loss: 0.229
Predicted string: tf the sea
epoch: 440, loss: 0.229
Predicted string: tf the sea
epoch: 441, loss: 0.229
Predicted string: tf the sea
epoch: 442, loss: 0.229
Predicted string: tf the sea
epoch: 443, loss: 0.229
Predicted string: tf the sea
epoch: 444, loss: 0.229
Predicted string: tf the sea
epoch: 445, loss: 0.229
Predicted string: tf the sea
epoch: 446, loss: 0.229
Predicted string: tf the sea
epoch: 447, loss: 0.229
Predicted string: tf the sea
epoch: 448, loss: 0.229
Predicted string: tf the sea
epoch: 449, loss: 0.229
Predicted string: tf the sea
epoch: 450, loss: 0.229
Predicted string: tf the sea
epoch: 451, loss: 0.229
Predicted string: tf the sea
epoch: 452, loss: 0.229
Predicted string: tf the sea
epoch: 453, loss: 0.230
Predicted string: tf the sea
epoch: 454, loss: 0.230
Predicted string: tf the sea
epoch: 455, loss: 0.230
Predicted string: tf the sea
epoch: 456, loss: 0.230
Predicted string: tf the sea
epoch: 457, loss: 0.230
Predicted string: tf the sea
epoch: 458, loss: 0.230
Predicted string: tf the sea
epoch: 459, loss: 0.229
Predicted string: tf the sea
epoch: 460, loss: 0.229
Predicted string: tf the sea
epoch: 461, loss: 0.229
Predicted string: tf the sea
epoch: 462, loss: 0.229
Predicted string: tf the sea
epoch: 463, loss: 0.229
Predicted string: tf the sea
epoch: 464, loss: 0.229
Predicted string: tf the sea
epoch: 465, loss: 0.229
Predicted string: tf the sea
epoch: 466, loss: 0.229
Predicted string: tf the sea
epoch: 467, loss: 0.229
Predicted string: tf the sea
epoch: 468, loss: 0.229
Predicted string: tf the sea
epoch: 469, loss: 0.229
Predicted string: tf the sea
epoch: 470, loss: 0.229
Predicted string: tf the sea
epoch: 471, loss: 0.229
Predicted string: tf the sea
epoch: 472, loss: 0.229
Predicted string: tf the sea
epoch: 473, loss: 0.229
Predicted string: tf the sea
epoch: 474, loss: 0.229
Predicted string: tf the sea
epoch: 475, loss: 0.229
Predicted string: tf the sea
epoch: 476, loss: 0.229
Predicted string: tf the sea
epoch: 477, loss: 0.229
Predicted string: tf the sea
epoch: 478, loss: 0.229
Predicted string: tf the sea
epoch: 479, loss: 0.229
Predicted string: tf the sea
epoch: 480, loss: 0.229
Predicted string: tf the sea
epoch: 481, loss: 0.229
Predicted string: tf the sea
epoch: 482, loss: 0.229
Predicted string: tf the sea
epoch: 483, loss: 0.229
Predicted string: tf the sea
epoch: 484, loss: 0.229
Predicted string: tf the sea
epoch: 485, loss: 0.229
Predicted string: tf the sea
epoch: 486, loss: 0.229
Predicted string: tf the sea
epoch: 487, loss: 0.229
Predicted string: tf the sea
epoch: 488, loss: 0.229
Predicted string: tf the sea
epoch: 489, loss: 0.229
Predicted string: tf the sea
epoch: 490, loss: 0.229
Predicted string: tf the sea
epoch: 491, loss: 0.229
Predicted string: tf the sea
epoch: 492, loss: 0.229
Predicted string: tf the sea
epoch: 493, loss: 0.229
Predicted string: tf the sea
epoch: 494, loss: 0.229
Predicted string: tf the sea
epoch: 495, loss: 0.229
Predicted string: tf the sea
epoch: 496, loss: 0.229
Predicted string: tf the sea
epoch: 497, loss: 0.229
Predicted string: tf the sea
epoch: 498, loss: 0.229
Predicted string: tf the sea
epoch: 499, loss: 0.229
Predicted string: tf the sea
epoch: 500, loss: 0.229
Predicted string: tf the sea
Learning finished!
In [ ]:
Content source: kiseyno92/SNU_ML
Similar notebooks: