-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.py
29 lines (20 loc) · 1.03 KB
/
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
import tensorflow as tf
from numpy import genfromtxt
trainingX = genfromtxt('datasets/trainingX.csv', delimiter=',')
trainingY = genfromtxt('datasets/trainingY.csv')
trainingX = tf.keras.utils.normalize(trainingX, axis=1)
testX = genfromtxt('datasets/testX.csv', delimiter=',')
testY = genfromtxt('datasets/testY.csv')
testX = tf.keras.utils.normalize(testX, axis=1)
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Dense(128, input_dim=31, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(601, activation=tf.nn.softmax))
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=[
'accuracy', tf.keras.metrics.SparseTopKCategoricalAccuracy(k=10)])
model.fit(trainingX, trainingY, epochs=10,
batch_size=32, validation_split=0.15)
model.evaluate(testX, testY)
model.save('models/network.model')