-
Notifications
You must be signed in to change notification settings - Fork 0
/
cnn_model.py
49 lines (33 loc) · 1.37 KB
/
cnn_model.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
42
43
44
45
46
47
48
49
'''
This file contains the function of the model
The CNN model NVIDIA architecture can be found at:
https://images.nvidia.com/content/tegra/automotive/images/2016/solutions/pdf/end-to-end-dl-using-px.pdf
'''
# Import necessary libraries
import tensorflow as tf
from tensorflow.keras import datasets, layers, models
from tensorflow.keras.optimizers import Adam
def nvidia_model():
model = models.Sequential()
# Layer 1
model.add(layers.Conv2D(24, (5, 5), strides = (2, 2), input_shape = (66, 200, 3), activation = 'elu'))
# Layer 2
model.add(layers.Conv2D(36, (5, 5), strides = (2, 2), activation = 'elu'))
# Layer 3
model.add(layers.Conv2D(48, (5, 5), strides = (2, 2), activation = 'elu'))
# Layer 4
model.add(layers.Conv2D(64, (3, 3), strides = (1, 1), activation = 'elu'))
# Layer 5
model.add(layers.Conv2D(64, (3, 3), strides = (1, 1), activation = 'elu'))
# Flatten
model.add(layers.Flatten())
# Full connected layer 1
model.add(layers.Dense(100, activation = 'elu'))
# Full connected layer 2
model.add(layers.Dense(50, activation = 'elu'))
# Full connected layer 3
model.add(layers.Dense(10, activation = 'elu'))
# Output layer
model.add(layers.Dense(1))
model.compile(optimizer = Adam(learning_rate = 0.0001), loss = 'mse')
return model