-
Notifications
You must be signed in to change notification settings - Fork 1
/
convolutional_neural_network.py
39 lines (36 loc) · 1.62 KB
/
convolutional_neural_network.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
from keras.optimizers import RMSprop
from keras.models import Sequential
from keras.layers import Conv2D, Flatten, Dense
class ConvolutionalNeuralNetwork:
def __init__(self, input_shape, action_space):
self.model = Sequential()
self.model.add(Conv2D(32,
8,
strides=(4, 4),
padding="valid",
activation="relu",
input_shape=input_shape,
data_format="channels_first"))
self.model.add(Conv2D(64,
4,
strides=(2, 2),
padding="valid",
activation="relu",
input_shape=input_shape,
data_format="channels_first"))
self.model.add(Conv2D(64,
3,
strides=(1, 1),
padding="valid",
activation="relu",
input_shape=input_shape,
data_format="channels_first"))
self.model.add(Flatten())
self.model.add(Dense(512, activation="relu"))
self.model.add(Dense(action_space))
self.model.compile(loss="mean_squared_error",
optimizer=RMSprop(lr=0.00025,
rho=0.95,
epsilon=0.01),
metrics=["accuracy"])
self.model.summary()