Instantly share code, notes, and snippets.

@samphippen /inception.py Secret
Created Nov 23, 2018

Embed
What would you like to do?
import tensorflow as tf
initializer = tf.initializers.random_normal(0.0, 0.03)
def conv(x, filters, kernel_size, strides=1):
return tf.layers.conv2d(
x,
filters=filters,
kernel_size=kernel_size,
activation=tf.nn.leaky_relu,
strides=strides,
padding="same",
kernel_initializer=initializer
)
def downsample(net, scale):
net = tf.layers.average_pooling2d(net, scale, scale)
return net
def inception_module(x, filters):
ones_5 = conv(x,filters, 1)
ones_3 = conv(x,filters, 1)
ones_1 = conv(x,filters, 1)
ones_max = conv(x,filters, 1)
net_5 = conv(ones_5, filters, 5)
net_3 = conv(ones_3, filters, 3)
net_1 = conv(ones_1, filters, 1)
net_max = tf.layers.max_pooling2d(ones_max, pool_size=3, padding='same', strides=1)
net = tf.concat([net_5, net_3, net_1, net_max],axis=3)
return net
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment