cifar10_tf.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:NetworkCompress 作者: luzai 项目源码 文件源码
def conv_layer(input, size_in, size_out, name="conv"):
    with tf.name_scope(name) as scope:
        w = tf.Variable(tf.truncated_normal([5, 5, size_in, size_out], stddev=0.1), name="W")
        b = tf.Variable(tf.constant(0.1, shape=[size_out]), name="B")
        conv = tf.nn.conv2d(input, w, strides=[1, 1, 1, 1], padding="SAME")
        act = tf.nn.relu(conv + b)
        tf.summary.histogram("weights", w)
        tf.summary.histogram("bias", b)
        tf.summary.histogram("activation", act)
        # act_list=tf.split(act,size_out,axis=)
        print(act.get_shape())
        # tf.Print(act,[act],message="!!!!!")
        # tf.Print(act,[act.get_shape()],message="!!!")
        # tf.Print(act,[tf.shape(act)],message="!!!!")

        x_min = tf.reduce_min(w)
        x_max = tf.reduce_max(w)
        weights_0_to_1 = (w - x_min) / (x_max - x_min)
        weights_0_to_255_uint8 = tf.image.convert_image_dtype(weights_0_to_1, dtype=tf.uint8)

        # to tf.image_summary format [batch_size, height, width, channels]
        weights_transposed = tf.transpose(weights_0_to_255_uint8, [3, 0, 1, 2])
        tf.summary.image('activation', weights_transposed)
        return tf.nn.max_pool(act, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding="SAME")


# Add fully connected layer
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号