title: How to convert trained convolutional network (CNN) to use as a detector?
body: <p>I am new in the computer vision and ML. After several exiting weeks with Python and TensorFlow  I have some questions.</p>
  <p>How to convert trained convolutional network (CNN) to use it as a detector? (get a heatmap)</p>
  <h2>For ex.:</h2>
  <h3>We have</h3>
  <p>trained MNIST model</p>
  <p>MODEL = [None, 28**2] &gt; [CONV3+POOL] &gt; [CONV3+POOL] &gt; [DENSELAYER] &gt; [None, 10]</p>
  <h3>I want:</h3>
  <p>[None, WH] &gt; [MODEL] &gt; [None, w, h, 10]</p>
  <p>I read that to do so it is necessary to convert the [DENSELAYER] into convolution. Am i right?</p>
  <p>Thank you in advance for your help and sorry for my english :) the old code looks like this:</p>
  <pre><code>    with tf.name_scope('dense_layer'):
          dense1 = tf.reshape(conv2, [-1, _weights['wd1'].get_shape().as_list()[0]])
          dense1 = tf.nn.relu(tf.matmul(dense1, _weights['wd1']) + _biases['bd1'])
          dense1 = tf.nn.dropout(dense1, dropout)
          out = tf.nn.softmax(tf.matmul(dense1, _weights['out']) + _biases['out'])
      return out
  </code></pre>
  <p>I think the first fully connected layer should be a 7x7 conv, but I'm not sure how to handle the second fc layer (the output layer):</p>
  <pre><code>    with tf.name_scope('conv_layer_3'):
          # ?????
          wc3 = tf.reshape(_weights['wd1'], [7, 7, w2, d1])
          conv3 = conv2d_valid(conv2, wc3, _biases['bd1'])
      with tf.name_scope('conv_layer_4'):
          # ???
      return out
  </code></pre>