-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathheir_lstm.py
31 lines (23 loc) · 875 Bytes
/
heir_lstm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
from keras.models import Sequential, Model
from keras.layers import LSTM, Input, concatenate, Reshape, RepeatVector
# from utils import *
nsent = 25
ignorelen = 15
training_set_size = 1400
nep = 3
output_size = 50
shared_unit = LSTM(output_size)
inputs = []
for i in range(nsent):
inputs.append(Input(shape=(None,output_size)))
encs = list(map(shared_unit, inputs))
reshaped_units = list(map(Reshape(target_shape=(1,output_size)), encs))
merged = concatenate(reshaped_units, axis=1)
final_layer = LSTM(output_size)(merged)
repeat_output = RepeatVector(10)(final_layer)
# reshape_encoder = Reshape(target_shape=(1,20))(final_layer)
decoder = LSTM(output_size,return_sequences=True)(repeat_output)
model = Model(inputs=inputs, outputs=decoder)
model.compile(loss='mean_squared_error', optimizer='rmsprop', metrics=[])
print("Model Compiled")