Created
June 11, 2018 16:31
-
-
Save benoitdescamps/2c51ac50255696847eae8a5f453f313c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def define_Q(input_shape=(16,16)): | |
""" | |
Defines the Q-matrix and returns the input and output tensorflow tensors. | |
Args: | |
:param Tuple input_shape: | |
:return: Tuple[tf.tensor, tf.tensor] | |
""" | |
input = tf.placeholder(shape=(None,)+input_shape+(1,), dtype=tf.float32) | |
nn_1 = tf.layers.batch_normalization(input) | |
filter_1 = tf.Variable(tf.random_normal([3, 3, 1, 4], stddev=1.0)) | |
layer_1 = tf.nn.conv2d(input=nn_1, strides=[1, 1, 1, 1], filter=filter_1, padding='VALID') | |
filter_2 = tf.Variable(tf.random_normal([3, 3, 4, 8], stddev=1.0)) | |
layer_2 = tf.nn.conv2d(input=layer_1, strides=[1, 1, 1, 1], filter=filter_2, padding='VALID') | |
filter_3 = tf.Variable(tf.random_normal([3, 3, 8, 16], stddev=1.0)) | |
layer_3 = tf.nn.conv2d(input=layer_2, strides=[1, 1, 1, 1], filter=filter_3, padding='VALID') | |
#layer_2 = tf.layers.max_pooling2d(inputs=layer_1, pool_size=(4, 4), strides=(1, 1)) | |
#remove maxpooling layer as translational invariance might not be necessary here | |
layer_3 = tf.layers.dense(inputs=tf.layers.Flatten()(layer_3) \ | |
, units=8, activation=tf.nn.relu, use_bias=True) | |
output = tf.layers.dense(inputs=layer_3, units=3, use_bias=True) | |
return input,output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment