import numpy as np
import tensorflow as tf
#input:x
x_image = tf.placeholder(tf.float32,shape=[4,4])
x = tf.reshape(x_image,[1,4,4,1])
#ksize & Stride & padding
ksize = [1,2,2,1]
strides=[1,2,2,1]
padding = 'VALID'
#max pooling
y = tf.nn.max_pool(x,ksize,strides,padding)
x_data = np.array([[4,3,1,8],[7,2,6,3],[2,0,1,1],[3,4,2,5]],
dtype = np.float32)
with tf.Session() as sess:
init = tf.initialize_all_variables()
sess.run(init)
x = (sess.run(x,feed_dict={x_image:x_data}))
y = (sess.run(y,feed_dict={x_image:x_data}))
print "The shape of x:\t", x.shape, ",\t and the x.reshpe(4,4) is :"
print x.reshape(4,4)
print ""
print "The shape of y:\t", y.shape, ",\t and the y.reshpe(2,2) is :"
print y.reshape(2,2)
print ""
import numpy as np
import tensorflow as tf
#input:x
x_image = tf.placeholder(tf.float32,shape=[4,4])
x = tf.reshape(x_image,[1,4,4,1])
#ksize & Stride & padding
ksize = [1,3,3,1]
strides=[1,1,1,1]
padding = 'VALID'
#max pooling
y = tf.nn.max_pool(x,ksize,strides,padding)
x_data = np.array([[4,3,1,8],[7,2,6,3],[2,0,1,1],[3,4,2,5]],
dtype = np.float32)
with tf.Session() as sess:
init = tf.initialize_all_variables()
sess.run(init)
x = (sess.run(x,feed_dict={x_image:x_data}))
y = (sess.run(y,feed_dict={x_image:x_data}))
print "The shape of x:\t", x.shape, ",\t and the x.reshpe(4,4) is :"
print x.reshape(4,4)
print ""
print "The shape of y:\t", y.shape, ",\t and the y.reshpe(2,2) is :"
print y.reshape(2,2)
print ""
import numpy as np
import tensorflow as tf
#input:x
x_image = tf.placeholder(tf.float32,shape=[4,4])
x = tf.reshape(x_image,[1,4,4,1])
#ksize & Stride & padding
ksize = [1,2,2,1]
strides=[1,1,1,1]
padding = 'VALID'
#max pooling
y = tf.nn.max_pool(x,ksize,strides,padding)
x_data = np.array([[4,3,1,8],[7,2,6,3],[2,0,1,1],[3,4,2,5]],
dtype = np.float32)
with tf.Session() as sess:
init = tf.initialize_all_variables()
sess.run(init)
x = (sess.run(x,feed_dict={x_image:x_data}))
y = (sess.run(y,feed_dict={x_image:x_data}))
print "The shape of x:\t", x.shape, ",\t and the x.reshpe(4,4) is :"
print x.reshape(4,4)
print ""
print "The shape of y:\t", y.shape, ",\t and the y.reshpe(2,2) is :"
print y.reshape(3,3)
print ""