Created
November 27, 2018 15:13
-
-
Save ispamm/f910a24b77b9da8f39794fe0d5ceedca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reimplement the feature extraction from the original paper | |
def extract_features(features): | |
# Input layer | |
input_layer = tf.reshape(features["x"], [-1, 40, 40, 3]) | |
# First convolutive layer | |
conv1 = tf.layers.conv2d(inputs=input_layer, filters=16, kernel_size=[5, 5], padding="same", activation=tf.nn.relu) | |
pool1 = tf.layers.max_pooling2d(inputs=conv1, pool_size=[2, 2], strides=2) | |
# Second convolutive layer | |
conv2 = tf.layers.conv2d(inputs=pool1, filters=48, kernel_size=[3, 3], padding="same", activation=tf.nn.relu) | |
pool2 = tf.layers.max_pooling2d(inputs=conv2, pool_size=[2, 2], strides=2) | |
# Third convolutive layer | |
conv3 = tf.layers.conv2d(inputs=pool2, filters=64, kernel_size=[3, 3], padding="same", activation=tf.nn.relu) | |
pool3 = tf.layers.max_pooling2d(inputs=conv3, pool_size=[2, 2], strides=2) | |
# Fourth convolutive layer | |
conv4 = tf.layers.conv2d(inputs=pool3, filters=64, kernel_size=[2, 2], padding="same", activation=tf.nn.relu) | |
# Dense Layer | |
flat = tf.reshape(conv4, [-1, 5 * 5 * 64]) | |
dense = tf.layers.dense(inputs=flat, units=100, activation=tf.nn.relu) | |
return dense |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment