Skip to content

Instantly share code, notes, and snippets.

@Muosvr
Last active October 14, 2018 01:59
Show Gist options
  • Save Muosvr/b1518200ce81dcc671610c78c853f361 to your computer and use it in GitHub Desktop.
Save Muosvr/b1518200ce81dcc671610c78c853f361 to your computer and use it in GitHub Desktop.
Base reference model of donkeycar pilot using Keras 3DCNN
#3DCNN base model
img_in3D = Input(shape=(3, 120, 160, 3), name='img_in')
x = img_in3D x = Cropping3D(cropping = ((0, 0),(60, 0),(0, 0)))(x)
x = Convolution3D(8, (3, 3, 3), strides=(1, 2, 2), activation='relu')(x)
x = MaxPooling3D(pool_size=(1, 2, 2))(x)
x = BatchNormalization()(x) x = Dropout(0.1)(x)
x = Flatten(name='flattened')(x)
x = Dense(50, activation='relu')(x)
x = Dropout(0.2)(x)
angle_out = Dense(15, activation='softmax', name='angle_out')(x)
throttle_out = Dense(1, activation='relu', name='throttle_out')(x)
model = Model(inputs=[img_in3D], outputs=[angle_out, throttle_out])
model.compile(optimizer='adam', loss={'angle_out':'categorical_crossentropy',
'throttle_out': 'mean_absolute_error'}, loss_weights={'angle_out': 0.9, 'throttle_out': 0.01})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment