Skip to content

Instantly share code, notes, and snippets.

View MTDzi's full-sized avatar

Maciej MTDzi

View GitHub Profile
@MTDzi
MTDzi / lenet_like_model.py
Last active November 25, 2018 14:22
Definition of the LeNet-like-model for controlling an autonomous car
def get_lenet_like_model(
input_shape, num_outputs,
l2_reg=1e-3, filter_sz=5, num_filters=24, num_dense_neurons=512,
):
inp = Input(input_shape)
x = Conv2D(num_filters, (filter_sz, filter_sz),
padding='same', kernel_regularizer=l2(l2_reg))(inp)
x = MaxPooling2D(2, 2)(x)
x = ELU()(x)
@MTDzi
MTDzi / clip_throttle.py
Created November 25, 2018 15:08
Throttle clipping function
def clip_throttle(throttle, curr_speed, target_speed):
return np.clip(
throttle - 0.1 * (curr_speed-target_speed),
0.25,
1.0
)
@MTDzi
MTDzi / lenet_like_embedder.py
Last active March 4, 2019 06:23
Definition of the LeNet-like embedder
def get_lenet_like_embedder(
input_shape,
act='elu', l2_reg=1e-3, filter_sz=5, num_filters=24, num_dense_neurons=512,
):
"""
Returns a 2-tuple of (input, embedding_layer) that can later be used
to create a model that builds on top of the embedding_layer.
"""
inp = Input(input_shape)
@MTDzi
MTDzi / multi_task_outputs.py
Last active March 7, 2019 08:29
Multi-task output layers built on top of an embedder
def add_throttle_upon_steer_w_odometry(
outputs_spec, embed_getter,
act='elu', l2_reg=1e-3, num_dense_neurons=512,
):
"""Build output layers on top of the embedding layer, and return a model.
An example of the `outputs_spec` argument is an OrderedDict specifying
the names of the output layers, their respective: activation function,
loss, and weight (multiplicative constant modifying the loss), e.g.: