title: How to retrain inception-v1 model?
body: <p>I have successfully gone through the <a href="https://www.tensorflow.org/versions/r0.9/how_tos/image_retraining/index.html" rel="nofollow">official tutorial</a>, which explains how to retrain inception-v3 model and later successfully retrained the same model o train the model for specific purposes.</p>
  
  <p>The model, however, is complex and slow compared to other, simpler models, such as inception-v1 which accuracy is good enough for some tasks. Specifically, I would like to retrain the model to use it on Android and ideally the performance in terms of speed should be comparable to original <a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android" rel="nofollow">TensorFlow Android demo</a>. Anyway, I tried to retrain the inception-v1 model from <a href="https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip" rel="nofollow">this link</a> with following modifications in retrain.py:</p>
  
  <pre><code>BOTTLENECK_TENSOR_NAME = 'avgpool0/reshape:0'
  BOTTLENECK_TENSOR_SIZE = 2048
  MODEL_INPUT_WIDTH = 224
  MODEL_INPUT_HEIGHT = 224
  MODEL_INPUT_DEPTH = 3
  JPEG_DATA_TENSOR_NAME = 'input'
  RESIZED_INPUT_TENSOR_NAME = 'input'
  </code></pre>
  
  <p>As opposed to inception v3, inception v1 does not have any decodeJpeg or resize nodes:</p>
  
  <p>inception v3 nodes:</p>
  
  <pre><code>DecodeJpeg/contents
  DecodeJpeg
  Cast
  ExpandDims/dim
  ExpandDims
  ResizeBilinear/size
  ResizeBilinear
  ...
  pool_3
  pool_3/_reshape/shape
  pool_3/_reshape
  softmax/weights
  softmax/biases
  softmax/logits/MatMul
  softmax/logits
  softmax
  </code></pre>
  
  <p>inception v1 nodes:</p>
  
  <pre><code>input
  conv2d0_w
  conv2d0_b
  conv2d1_w
  conv2d1_b
  conv2d2_w
  conv2d2_b
  ...
  softmax1_pre_activation
  softmax1
  avgpool0/reshape/shape
  avgpool0/reshape
  softmax2_pre_activation/matmul
  softmax2_pre_activation
  softmax2
  output
  output1
  output2
  </code></pre>
  
  <p>so I guess the images have to be reshaped before being fed into the graph.</p>
  
  <p>Right now the error occurs when hitting the following function:</p>
  
  <pre><code>def run_bottleneck_on_image(sess, image_data, image_data_tensor,
                              bottleneck_tensor):
    """Runs inference on an image to extract the 'bottleneck' summary layer.
  
    Args:
      sess: Current active TensorFlow Session.
      image_data: Numpy array of image data.
      image_data_tensor: Input data layer in the graph.
      bottleneck_tensor: Layer before the final softmax.
  
    Returns:
      Numpy array of bottleneck values.
    """
  
    bottleneck_values = sess.run(
        bottleneck_tensor,
        {image_data_tensor: image_data})
    bottleneck_values = np.squeeze(bottleneck_values)
    return bottleneck_values
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>TypeError: Cannot interpret feed_dict key as Tensor: Can not convert a
    Operation into a Tensor.</p>
  </blockquote>
  
  <p>I guess the data on input node of inception v1 graph has to be reshaped to match the data after passing the following nodes in inception v3:</p>
  
  <pre><code>DecodeJpeg/contents
  DecodeJpeg
  Cast
  ExpandDims/dim
  ExpandDims
  ResizeBilinear/size
  ResizeBilinear
  </code></pre>
  
  <p>If anyone has already managed to retrain the inception v1 model or has an idea how to reshape the data in inception v1 case to match inception v3, I would be very thankful for any tips or suggestions.</p>