title: TFSlim - problems loading saved checkpoint for VGG16
body: <p>(1) I'm trying to fine-tune a VGG-16 network using TFSlim by loading pretrained weights into all layers except the<code>fc8</code> layer. I achieved this by using the TF-SLIm function as follows:</p>
  
  <pre><code>import tensorflow as tf
  import tensorflow.contrib.slim as slim
  import tensorflow.contrib.slim.nets as nets
  
  vgg = nets.vgg
  
  # Specify where the Model, trained on ImageNet, was saved.
  model_path = 'path/to/vgg_16.ckpt'
  
  # Specify where the new model will live:
  log_dir = 'path/to/log/'
  
  images = tf.placeholder(tf.float32, [None, 224, 224, 3])
  predictions = vgg.vgg_16(images)
  
  variables_to_restore = slim.get_variables_to_restore(exclude=['fc8'])
  restorer = tf.train.Saver(variables_to_restore)
  
  
  
  
  init = tf.initialize_all_variables()
  
  with tf.Session() as sess:
     sess.run(init)
     restorer.restore(sess,model_path)
     print "model restored"
  </code></pre>
  
  <p>This works fine as long as I do not change the <code>num_classes</code> for the VGG16 model. What I would like to do is to change the <code>num_classes</code> from 1000 to 200. I was under the impression that if I did this modification by defining a new <code>vgg16-modified</code> class that replaces the <code>fc8</code> to produce 200 outputs, (along with a <code>variables_to_restore = slim.get_variables_to_restore(exclude=['fc8'])</code>  that everything will be fine and dandy.  However, tensorflow complains of a dimensions mismatch:</p>
  
  <pre><code>InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [1,1,4096,200] rhs shape= [1,1,4096,1000] 
  </code></pre>
  
  <p>So, how does one really go about doing this ? The documentation for TFSlim is really patchy and there are several versions scattered on Github - so not getting much help there. </p>