Skip to content

Commit

Permalink
Add kernel regularizer to classifier
Browse files Browse the repository at this point in the history
  • Loading branch information
ndrplz committed Oct 16, 2017
1 parent da81c07 commit dce2e6e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions capstone_traffic_light_classifier/traffic_light_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ def inference(self):
if self._inference is None:
with tf.variable_scope('inference'):

kernel_regularizer = tf.contrib.layers.l2_regularizer(1e-3)

conv1_filters = 32
conv1 = tf.layers.conv2d(self.x, conv1_filters, kernel_size=(3, 3), padding='same', activation=tf.nn.relu)
conv1 = tf.layers.conv2d(self.x, conv1_filters, kernel_size=(3, 3), padding='same',
activation=tf.nn.relu, kernel_regularizer=kernel_regularizer)
pool1 = tf.layers.max_pooling2d(conv1, pool_size=(2, 2), strides=(2, 2), padding='same')

conv2_filters = 64
conv2 = tf.layers.conv2d(pool1, conv2_filters, kernel_size=(3, 3), padding='same', activation=tf.nn.relu)
conv2 = tf.layers.conv2d(pool1, conv2_filters, kernel_size=(3, 3), padding='same',
activation=tf.nn.relu, kernel_regularizer=kernel_regularizer)
pool2 = tf.layers.max_pooling2d(conv2, pool_size=(2, 2), strides=(2, 2), padding='same')

_, h, w, c = pool2.get_shape().as_list()
Expand Down

0 comments on commit dce2e6e

Please sign in to comment.