我基于DEEP MNIST Expert教程构建了一个7层的卷积网络,并额外添加了两个卷积层。
网络运行良好,但我希望尝试直接将1024 x 10的数组输入到全连接层,绕过卷积层。
有没有办法在不重建整个网络的情况下实现这一点?
回答:
在卷积层和全连接层之间,为全连接层的输入创建一个占位符:input_to_fc = tf.placeholder_with_default(previous_layer, shape=(None, 1024*10))
。你可以通过直接将输入 Feeding到input_to_fc
张量来绕过卷积层。
示例:
...conv = tf.layers.conv2d(...)flatten = tf.layers.flatten(...)input_to_fc = tf.placeholder_with_default(flatten, shape=OUTPUT_SHAPE_OF_PREVIOUS_LAYER))fc = tf.layers.dense(input_to_fc, ...)