-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathneural.py
41 lines (32 loc) · 1.06 KB
/
neural.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
41
import csv
from keras.models import Sequential
from keras.layers import Dense, Dropout, BatchNormalization
from sklearn import model_selection
import numpy
from random import shuffle
# seed
seed_ = 5
numpy.random.seed(seed_)
def ANN():
dataset = numpy.loadtxt('train_data.csv', delimiter=',')
Xtrain = dataset[:, :8]
Ytrain = dataset[:, 8]
model = Sequential()
model.add(Dense(8, input_dim=8, activation='relu'))
model.add(BatchNormalization())
model.add(Dropout(0.5))
model.add(Dense(8, activation='relu'))
model.add(BatchNormalization())
model.add(Dropout(0.5))
model.add(Dense(4, activation='relu'))
model.add(BatchNormalization())
model.add(Dropout(0.5))
model.add(Dense(1, activation='relu'))
# Compile model
model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
print(model.summary())
model.fit(Xtrain, Ytrain, epochs=5, batch_size=16, verbose=1)
# print(model.predict(Xtrain))
# print(Ytrain)
if __name__ == '__main__':
ANN()