Problems about get_variable() and variable_scope()
<p>I retrained the inception-V3 model according to the image_retrain example with one extra conv and pool layers on the top of the original bottleneck layer. The two layers are initialized with <code>get_variable()</code> function
in a <code>variable_scope()</code> and after training the graph and parameters are stored in a <code>.pb</code> file.
But when I read the just trained <code>.pb</code> file for test and want to retrieve the variables in the two layers, with <code>variable_scope()</code> and <code>get_variable(,reuse=true)</code>, exception are raised about</p>

<blockquote>
  <p>Variable weights/W does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?'</p>
</blockquote>

<p><strong>Environment Information -</strong></p>

<p><strong><em>Operating System</em></strong>: Ubuntu 14.04</p>

<p><strong><em>Installed version of CUDA and cuDNN</em></strong>:
cuda 8.0
cudnn 5.1</p>

<blockquote>
  <p>I tensorflow/stream_executor/dso_loader.cc:128] successfully opened
  CUDA library libcublas.so locally</p>
  
  <p>I tensorflow/stream_executor/dso_loader.cc:128] successfully opened
  CUDA library libcudnn.so locally</p>
  
  <p>I tensorflow/stream_executor/dso_loader.cc:128] successfully opened
  CUDA library libcufft.so locally</p>
  
  <p>I tensorflow/stream_executor/dso_loader.cc:128] successfully opened
  CUDA library libcuda.so.1 locally</p>
  
  <p>I tensorflow/stream_executor/dso_loader.cc:128] successfully opened
  CUDA library libcurand.so locally</p>
  
  <p>0.12.0-rc0</p>
</blockquote>

<p>I initialize the two extra layers as:</p>

<pre><code>  with tf.variable_scope('CAM_unit'):
      CAM_conv = new_conv_layer(bottleneck_input,   [3,3,BOTTLENECK_TENSOR_SIZE,BOTTLENECK_TENSOR_SIZE], 'CAM_CONV')
      CAM_pool = tf.reduce_mean(tf.nn.relu(CAM_conv), [1,2], name='CAM_AVG_POOL')
  with tf.variable_scope('weights'):
      layer_weights = tf.get_variable('W', 
                                      shape = [BOTTLENECK_TENSOR_SIZE, class_count], 
                                      initializer = tf.random_normal_initializer(0., 0.01))
</code></pre>

<p>And access the weights/W variables as:</p>

<pre><code>with tf.variable_scope('weights', reuse=True):
        label_w = tf.gather(tf.transpose(tf.get_variable('W')), label)
</code></pre>

<p>I tried to set <code>reuse=None</code>, but the error is:</p>

<blockquote>
  <p>Shape of a new variable (weights/W) must be fully defined, but instead was </p>
</blockquote>

<p>I doubt about the <code>.pb</code> file in which the model converged with a very high accuracy, because when I retrain again with this output <code>.pb</code> file, the accuracy is very low like an untrained one. But I imported the model, the new added layers are there as expected, just inaccessible with <code>get_variable()</code>
I import the <code>.pb</code> file and search for the target layers with code:</p>

<pre><code>ops = [op.name for op in graph.get_operations() if 'weights/' in op.name]
    pprint.pprint(ops)
</code></pre>

<p>and find the weights/W variables are available:</p>

<pre><code>[u'weights/W', u'weights/W/read']
</code></pre>