System deep learning and message predicting results

Một phần của tài liệu Developing a virtual sales assistant using deep learning faculty of high quality training graduations thesis of the information technology (Trang 80 - 82)

➢ Question:

➢ Research process: "tag": "Lời Chào",

"patterns": ["Xin chào", "Tôi cần giúp đỡ"], "responses": [

"Xin chào quý khách. Hãy hỏi, <hướng dẫn>, để biết thêm thông tin về tôi nhé",

"Xin chào. Mình có thể hỗ trợ gì cho bạn không? Bạn có thể hỏi <Hướng dẫn sử dụng>."],

70 • At first, the model used was from the tflearn package:

• The model uses an input layer of length equal to the length of the training data, 2 hidden layers fully connected for 8 output dim, an ouput layer equal to the length of the training label, and uses an activation of "softmax". • With this model, the system is perfect, but the ability is not good. This

package is currently older than tensorflow keras package. So we decided to move the model from tflearn to tensorflow keras. Here is the model from tensorflow keras:

model = keras.models.Sequential([

keras.layers.Input(shape=(< length of training data >)), keras.layers.Dense(128, activation='relu'),

keras.layers.Dropout(0.5),

keras.layers.Dense(64, activation='relu'), keras.layers.Dropout(0.5),

keras.layers.Dense(<length of training label>, activation='softmax')]) optimizer = 'Adam'

model.compile(loss="categorical_crossentropy",optimizer=optimizer, metrics=["accuracy"])

model.fit(<data>, <label>, epochs=500, batch_size=5, verbose=1) tf.compat.v1.reset_default_graph()

net = tflearn.input_data(shape=[None, <length of training data>]) # input layer

net = tflearn.fully_connected(net, 8) # 8 neuron hidden layer net = tflearn.fully_connected(net, 8) # 8 neuron hidden layer

net = tflearn.fully_connected(net, len(output[0]), activation="softmax") #output layer

net = tflearn.regression(net) model = tflearn.DNN(net)

model.fit(<data>, <label>, n_epoch=1000, batch_size=8, show_metric = True)

71 • The first is to initialize the Sequential model for the problem.

• Input is a one-dimensional array of the same size as the training data length.

• Dense is a way to declare a neural network layer in Keras, with output_dim being the output dimension of that layer, and activation is the activation function of the layer.

• Dropout layer used as regularization for layers with limited overfitting. • The output of the problem will use the activation function to calculate the

probability (activation ="softmax").

• The compile function is the function needed to identify the optimizers during training.

• Loss= “categorical crossentropy”: use in multiclass classification. ➢ Solutions:

• Using Model in Tensorflow Keras.

Một phần của tài liệu Developing a virtual sales assistant using deep learning faculty of high quality training graduations thesis of the information technology (Trang 80 - 82)