Created
July 31, 2016 22:22
-
-
Save ericjang/c7740033e0082d6c4fab7e2862d37665 to your computer and use it in GitHub Desktop.
alternating convolution & upsampling in TensorFlow
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
#!/bin/env python | |
# uses tf-slim from release 0.10.0 | |
import tensorflow as tf | |
slim = tf.contrib.slim | |
batch = 13 | |
in_height, in_width, in_channels = 7, 7, 512 | |
x = tf.ones([batch, in_height, in_width, in_channels]) | |
print(x.get_shape()) | |
b,h,w,c = x.get_shape().as_list() | |
for i in range(3): | |
c /= 2 | |
h *= 2 | |
w *= 2 | |
# kernel = tf.Variable(tf.truncated_normal([3, 3, in_channels, out_channels])) | |
# conv = tf.nn.conv2d(x, kernel, [1, 1, 1, 1], padding='SAME') | |
x = slim.conv2d(x,c,[3,3]) | |
x = tf.image.resize_images(x,h,w) | |
print(x.get_shape()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment