def conv_max_pool_2x2(x, conv_width, conv_height, in_depth, out_depth, name="conv"):
with tf.name_scope(name) as scope:
W_conv = weight_variable([conv_width, conv_height, in_depth, out_depth])
b_conv = bias_variable([out_depth])
h_conv = tf.nn.relu(conv2d(x, W_conv) + b_conv)
h_pool = max_pool_2x2(h_conv)
with tf.name_scope("summaries") as scope:
# TIPS: to display the 32 convolution filters, re-arrange the
# weigths to look like 32 images with a transposition.
a = tf.reshape(W_conv, [conv_width * conv_height * in_depth, out_depth])
b = tf.transpose(a)
c = tf.reshape(b, [out_depth, conv_width, conv_height * in_depth, 1])
conv_image = tf.image_summary(name + " filter", c, out_depth)
# TIPS: by looking at the weights histogram, we can see the the
# weigths are explosing or vanishing.
W_conv_hist = tf.histogram_summary(name + " weights", W_conv)
b_conv_hist = tf.histogram_summary(name + " biases", b_conv)
return h_pool
评论列表
文章目录