简体   繁体   中英

How can I test individual layers in TensorFlow?

I have constructed a 7 layer convolutional network, based off of the DEEP MNIST Expert tutorial. I have added two more convolutional layers.

Everything runs well, but I would like to attempt to input 1024 x 10 arrays directly into the fully connected layer, and circumvent the convolutional layers.

Is there any way to do this without rebuilding the entire network?

Between the convolutional layers and the fully connected layer, create a place holder for the input to the fully connected layer: input_to_fc = tf.placeholder_with_default(previous_layer, shape=(None, 1024*10)) . You can bypass the convolutional layers by feeding the input directly to the input_to_fc tensor.

Example:

...
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, ...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM