【发布时间】:2016-04-30 07:11:24
【问题描述】:
问题:我将基本的 MNIST 示例从 Tensorflow 转换为完全卷积的实现。现在 100 次迭代所花费的时间大约是以前的 20 倍。这是什么原因造成的?
我从 Tensorflow 网站获取了基本的 MNIST 示例。现在我将最终的 FC 层转换为卷积层,灵感来自 this post by Yann LeCunn 和 this Quora post,或者更一般地说,文章 Fully Convolutional Networks for Semantic Segmentation
所以我改变了这个代码块
with tf.name_scope("Fully_Connected") as scope:
W_fc1 = weight_variable([7**2 * 64, 1024], 'Fully_Connected_layer_1')
b_fc1 = bias_variable([1024], 'bias_for_Fully_Connected_Layer_1')
h_pool2_flat = tf.reshape(h_pool2, [-1, 7**2*64])
h_fc1 = tf.nn.relu(tf.matmul(h_pool2_flat, W_fc1) + b_fc1)
到这个代码块
with tf.name_scope("FC_conv") as scope:
W_fcc1 = weight_variable([7,7,64,1024],'FC_conv_1')
b_fcc1 = bias_variable([1024],'bias_for_FC_conv_1')
h_fcc1 = tf.nn.relu(tf.nn.conv2d(h_pool2, W_fcc1, strides=[1, 1, 1, 1], padding='VALID')+b_fcc1)
进行此更改后,100 次迭代需要 70 秒,而不是几秒。也就是说,FC 实现 100 次迭代大约需要 5 秒。 full-conv 实现 100 次迭代大约需要 70 秒。
有人可以给我一个线索吗?为什么这种卷积实现需要这么多时间?
非常感谢您的时间和回答
【问题讨论】:
标签: neural-network tensorflow conv-neural-network