This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# shuffle our features and turn into np.array as tensorflow takes in numpy array | |
random.shuffle(training) | |
training = np.array(training) | |
# trainX contains the Bag of words and train_y contains the label/ category | |
train_x = list(training[:, 0]) | |
train_y = list(training[:, 1]) | |
# reset underlying graph data | |
tf.reset_default_graph() | |
# Build neural network | |
net = tflearn.input_data(shape=[None, len(train_x[0])]) | |
net = tflearn.fully_connected(net, 8) | |
net = tflearn.fully_connected(net, 8) | |
net = tflearn.fully_connected(net, len(train_y[0]), activation='softmax') | |
net = tflearn.regression(net) | |
# Define model and setup tensorboard | |
model = tflearn.DNN(net, tensorboard_dir='tflearn_logs') | |
# Start training (apply gradient descent algorithm) | |
model.fit(train_x, train_y, n_epoch=1000, batch_size=8, show_metric=True) | |
model.save('model.tflearn') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment