title: Adding DROPOUT to Tensorflow CIFAR10 Deep CNN Example
body: <p>I am looking to add dropout to the tensorflow CIFAR10 tutorial example code, but am having some difficulty.</p>
  
  <p>The Deep MNIST tensorflow tutorial includes an example of dropout, however it uses an interactive graph, which is different to the approach used for the CIFAR10 tutorial. Also, the CIFAR10 tutorial does not make use of placeholders, nor does it use a feed_dict to pass variables to the optimizer, which is used by the MNIST model to pass the dropout probability for training. </p>
  
  <p>What I am trying:</p>
  
  <p>Within cifar10_train.train() I define the dropout probability placeholder, under the default graph; that is:</p>
  
  <pre><code>def train():
    """Train CIFAR-10 for a number of steps."""
    with tf.Graph().as_default():
      global_step = tf.Variable(0, trainable=False)
      keep_drop_prob = = tf.placeholder(tf.float32)
  </code></pre>
  
  <p>Underneath, still within the train() module, when I build the compute graph by calling cifar10.inference() I also pass the keep_drop_prob placeholder, like so:</p>
  
  <pre><code>"""Build a Graph that computes the logits predictions from the
  inference model."""
  logits = cifar10.inference(images, keep_drop_prob)
  </code></pre>
  
  <p>Within the cifar10.inference() module, I now take the keep_drop_prob placeholder that was passed and use it to define my dropout layer, like so:</p>
  
  <pre><code>drop1 = tf.nn.dropout(norm1, keep_drop_prob)
  </code></pre>
  
  <p>Now I define and pass a value for keep_drop_prob when calculating the loss, still within the train() module, like so:</p>
  
  <pre><code>"""Calculate loss."""
  loss = cifar10.loss(logits, labels, keep_drop_prob = 0.5)
  </code></pre>
  
  <p>Then within the cifar10.loss() module, I use the passed keep_drop_prob value, when calculating my cross entropy, like so:</p>
  
  <pre><code>"""Calculate the average cross entropy loss across the batch."""
  labels = tf.cast(labels, tf.int64)
  cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(
      logits, labels, keep_drop_prob, name='cross_entropy_per_example')
  </code></pre>
  
  <p>Now at this point, I am unsure if what I have done so far is correct, and what I need to do next. </p>
  
  <p>Any help would be greatly appreciated!</p>