with tf.variable_scope('local3') as scope:
# 第一层全连接
reshape = tf.reshape(pool2, [BATCH_SIZE,-1])
dim = reshape.get_shape()[1].value
weights = variables('weights', shape=[dim,384], stddev=0.004)
biases = variable_on_cpu('biases', [384])
# ReLu 激活函数
local3 = tf.nn.relu(tf.matmul(reshape, weights)+biases,
name = scope.name)
其中的BATCH_SIZE是一个batch的大小,因为网络的输入必定是一张图片,而一个batch里有
为[BATCH_SIZE,-1]形状。
总之,前面的卷积和池化的BATCH_SIZE张图片都是放在一起进行,而到全链接时,换了一种更
高效的数据组织方式(reshape),将batch内每一张图片全链接,详细类似推导时的转置。