Tech With Tim Logo
Go back

Part 3

Developing a Model

Now that we have preprocessed all of our data we are ready to start creating and training a model. For our purposes we will use a fairly standard feed-forward neural network with two hidden layers. The goal of our network will be to look at a bag of words and give a class that they belong too (one of our tags from the JSON file).

We will start by defining the architecture of our model. Keep in mind that you can mess with some of the numbers here and try to make an even better model! A lot of machine learning is trial an error.


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)

If you're new to neural networks and want some clarification to what all this means check out my Neural Network Tutorial Series.

Training & Saving the Model

Now that we have setup our model its time to train it on our data! To do these we will fit our data to the model. The number of epochs we set is the amount of times that the model will see the same information while training., output, n_epoch=1000, batch_size=8, show_metric=True)"model.tflearn")

Once we are done training the model we can save it to the file model.tflearn for use in other scripts.

In the next tutorial we will start using our model and chatting with it!

Design & Development by Ibezio Logo