問題:我將Tensorflow中的基本MNIST示例轉換爲完全卷積實現。現在100次迭代所需時間比以前大約多20倍。這是什麼原因?爲什麼TensorFlow中完全轉換層比FC層需要更多時間?
我從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實現花費了5秒100次迭代。全循環實施需要大約70秒100次迭代。
有人可以給我一個線索嗎?爲什麼這種卷積實現需要更多時間?
非常感謝您的時間和答案