Last active
March 4, 2019 16:55
-
-
Save eladshabi/b9957db1b5d4feff8d6de824af4f7bad to your computer and use it in GitHub Desktop.
Conv2d by dtype
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
# source: https://github.com/hwalsuklee/tensorflow-generative-model-collections/blob/master/ops.py | |
def conv2d(input_, output_dim, k_h=5, k_w=5, d_h=2, d_w=2, stddev=0.02, name="conv2d", | |
data_type=tf.float32): | |
with tf.variable_scope(name): | |
w = tf.get_variable('w', [k_h, k_w, input_.get_shape()[-1], output_dim], | |
initializer=tf.truncated_normal_initializer(stddev=stddev), | |
dtype=data_type) | |
conv = tf.nn.conv2d(input_, w, strides=[1, d_h, d_w, 1], padding='SAME') | |
biases = tf.get_variable('biases', [output_dim], | |
initializer=tf.constant_initializer(0.0), | |
dtype=data_type) | |
conv = tf.reshape(tf.nn.bias_add(conv, biases), conv.get_shape()) | |
return conv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment