-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmodel_train.py
40 lines (31 loc) · 1.24 KB
/
model_train.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
32
33
34
35
36
37
38
39
40
import tflearn
import tensorflow
from data_process import data_process
# # change philosopher name here
# philosopher_name = ""
# [words, labels, training, output] = data_process(
# "intent", "pikl", philosopher_name)
def model_train(training, output, philosopher_name):
# tensorflow.reset_default_graph()
# comment out line 16 until 27 if you want to retrain the model
# try:
# net = tflearn.input_data(shape=[None, len(training[0])])
# net = tflearn.fully_connected(net, 8)
# net = tflearn.fully_connected(net, 8)
# net = tflearn.fully_connected(
# net, len(output[0]), activation="softmax")
# net = tflearn.regression(net)
# model = tflearn.DNN(net)
# model.load(philosopher_name + "_model.tflearn")
# except:
net = tflearn.input_data(shape=[None, len(training[0])])
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(
net, len(output[0]), activation="softmax")
net = tflearn.regression(net)
model = tflearn.DNN(net)
model.fit(training, output, n_epoch=1000,
batch_size=8, show_metric=True)
model.save(philosopher_name + "_model.tflearn")
return model