-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAI.py
30 lines (23 loc) · 924 Bytes
/
AI.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
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation
from keras.optimizers import RMSprop
import keras.models
class AI:
@staticmethod
def load_model():
try:
model = keras.models.load_model('6Nimmt.h5')
except OSError or ValueError:
print("No previously trained model found! Creating new one...")
model = Sequential()
model.add(Dense(1024, init='lecun_uniform', input_shape=(456,), activation='relu'))
# model.add(Dropout(0.2))
model.add(Dense(1024, init='lecun_uniform', activation='relu'))
# model.add(Dropout(0.2))
model.add(Dense(104, init='lecun_uniform', activation='relu'))
rms = RMSprop()
model.compile(loss='mse', optimizer=rms)
return model
@staticmethod
def save_model(model):
model.save('6Nimmt.h5')