#代码问题
来源:4-5 VGG-ResNet实战(2)
战战的坚果
2020-03-24
conv3 = tf.layers.conv2d(pooling2,
32, # output channel number
(3,3), # kernel size
padding = ‘same’,
activation = tf.nn.relu,
name = ‘conv3’)
pooling3 = tf.layers.max_pooling2d(conv3,
(2, 2), # kernel size
(2, 2), # stride
name = ‘pool3’)
flatten = tf.layers.flatten(pooling3)
y_ = tf.layers.dense(flatten, 10)
与
conv3 = tf.layers.conv2d(pooling2,
32, # output channel number
(3,3), # kernel size
padding = ‘same’,
activation = tf.nn.relu,
name = ‘conv3’)
global_pool = tf.reduce_mean(conv3 , [1,2])
y_ = tf.layers.dense(global_pool, 10)
提问:老师,这两段代码是一模一样的嘛?
1回答
-
兄弟,你的代码连缩进也没有看得我真是头大。。
你是想问pooling + flatten + dense和reduce_mean + dense是不是一样吧?答案是如果pooling是average poolong且结果的图片大小就是1x1的,那么就是等价的。否则,reduce_mean相对前者就会有损失。
012020-03-25
相似问题