title: Changing a trained network to keep only a subset of its output
body: <p>Suppose I have a trained TensorFlow classification network for 20 classes as in PASCAL VOC 2007: aeroplane, bicycle, ..., car, cat, ..., person, ..., tvmonitor.</p>
  
  <p>Now, I would like to have a sub-network for only a <strong>subset of the classes</strong>, e.g., 3 classes: car, cat, person.</p>
  
  <p>Then, I can use this network for testing or for re-training/fine-tuning on a new dataset, only for the 3 classes.</p>
  
  <p><strong>It should be possible to extract this sub-network out of the original network, since it is only the last layer that will change.</strong> We need to discard the neurons/weights for the discarded classes.</p>
  
  <p><strong>My question:</strong> Is there an easy way to do this in TensorFlow?
  It will be great if you can point to some sample code or similar solution.
  I have googled, but have not come across any mention of this.</p>
  
  <p>The symmetric problem, expanding the number of classes without discarding the original weights, can potentially be useful for some people, but my current focus is the one above.</p>