Retraining variables from inception5h model

1,418 views
Skip to first unread message

vighnesh...@gmail.com

unread,
Jun 15, 2016, 2:38:28 PM6/15/16
to Discuss
Hello

I am trying to retrain the inception model downloaded from

However, everything in this model seems like it is an operation and there are no variables for me to train/reinitialize. Is it possible to retrain this model ?

I also followed the tutorial here

But the suggested model there only supports inputting one image at a time, where as I would like to supply images in batches

Thanks
Vighnesh

Pete Warden

unread,
Jun 15, 2016, 3:43:25 PM6/15/16
to vighnesh...@gmail.com, Discuss, Jon Shlens
Hi Vighnesh,
                     it's definitely possible to retrain that Inception model (which roughly corresponds to the original v1 GoogLeNet paper). You would just need to alter the input operations in the retrain.py script to feed image data to input:0 (instead of Mul:0) and alter the top layer rewriting code to cope with the new output node name.

I would recommend sticking with the newer Inception that's the default for the retraining example though, because it's significantly more accurate. One alternative is to look at the full model retraining script, which does support batches I believe:


Pete

--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
To post to this group, send email to dis...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/b3d5da97-a0cd-4520-8eaf-86731bce05f1%40tensorflow.org.

vighnesh...@gmail.com

unread,
Jun 15, 2016, 7:59:02 PM6/15/16
to Discuss, vighnesh...@gmail.com, shl...@google.com
Hello

Thanks for the quick reply. I was able to find the checkpoint file mentioned in the link you posted and it serves my purpose well.
tar xzf inception-v3-2016-03-01.tar.gz

It might be better if all the downloadable models were organized on a single webpage.

Thanks
Vighnesh
Message has been deleted

markw...@gmail.com

unread,
Oct 20, 2016, 4:51:03 PM10/20/16
to Discuss, vighnesh...@gmail.com, shl...@google.com
Hi,

I am trying to do something similar. I have generated a checkpoint with flowers_train.py and now I would like to export that graph to a format that I can then feed into 
in place of inception.pb in inception5h.zip

I attempted to export an input graph from inception_train.py along with the checkpoint and feed these into freeze_graph.py, but the graph still has a different structure from the original inception.pb. It is not even clear to me whether I can feed in a raw input image or if the graph I exported will only take TFRecords.

Is it documented somewhere how one can build their own inception.pb that takes jpg/png files as input?

Thanks!

Niko Gamulin

unread,
Oct 27, 2016, 4:54:27 PM10/27/16
to Discuss
Hi Peter,

After successfully retraining inception-v3, I have tried to retrain inception5h but unfortunately, haven't succeeded. At first, it turned out that I had to use TensorFlow version 0.8 in order to successfully read the inception5h .pb file. Then I observed the names of the layers in order to modify variables BOTTLENECK_TENSOR_NAME, JPEG_DATA_TENSOR_NAME, and RESIZED_INPUT_TENSOR_NAME. To be honest I am not sure how these names should be set. In case of inception v-3 model, the architecture looks like the following:
['DecodeJpeg/contents']
['DecodeJpeg/contents', '0']
['DecodeJpeg']
['DecodeJpeg', '0']
['Cast']
['ExpandDims/dim']
['Cast', '0']
['ExpandDims/dim', '0']
['ExpandDims']
['ResizeBilinear/size']
['ExpandDims', '0']
['ResizeBilinear/size', '0']
['ResizeBilinear']
['Sub/y']
['ResizeBilinear', '0']
['Sub/y', '0']
['Sub']
['Mul/y']
['Sub', '0']
...
['softmax/logits/MatMul', '0']
['softmax/biases', '0']
['softmax/logits']
['softmax/logits', '0']
['pool_3/_reshape', '0']
['DecodeJpeg/contents', '0']
['ResizeBilinear', '0']

whereas in inception5h it looks like the following:
['input']
['conv2d0_w']
['input', '0']
['conv2d0_w', '0']
['conv2d0_pre_relu/conv']
['conv2d0_b']
['conv2d0_pre_relu/conv', '0']
['conv2d0_b', '0']
['conv2d0_pre_relu']
['conv2d0_pre_relu', '0']
['conv2d0']
['conv2d0', '0']
['maxpool0']
...
['softmax0', '0']
['softmax1']
['softmax1', '0']
['softmax2']
['softmax2', '0']
['pool_3/_reshape', '0']

At first, according to names above, I guessed that BOTTLENECK_TENSOR_NAME should be set in both cases to 'pool_3/_reshape:0' but in case of inception v1 it threw an error. Also, I am not sure what should be the value of BOTTLENECK_TENSOR_SIZE.

Anyway, I am struggling to retrain inception5h model and would really appreciate if anyone could provide any additional insights. And by the way, the reason to retrain inception5h, is to use the custom model in Android app as the inception-v3 (without modifications) is too complex for real-time object detection on mobile platform.

Pete Warden

unread,
Oct 27, 2016, 5:08:40 PM10/27/16
to Niko Gamulin, Discuss
Unfortunately the Inceptionv5 graph isn't easily compatible with the retrain.py script, because it doesn't contain a DecodeJpeg op, requires a different input size (224 instead of 299), and you need to subtract 117 and do no divide of the input values, rather than subtracting 128 and dividing by 128 as happens in the v3 graph. If you can get past those issues, then the raw input node is 'input', and the bottleneck should be 'pool3/_reshape' I believe.

To unsubscribe from this group and stop receiving emails from it, send an email to discuss+unsubscribe@tensorflow.org.

To post to this group, send email to dis...@tensorflow.org.

Niko Gamulin

unread,
Oct 28, 2016, 4:00:04 PM10/28/16
to Discuss
Thanks Peter!
I have checked tensor names, by adding the following lines to retrain.py:
for tensor in tf.get_default_graph().as_graph_def().node:
print(tensor.name)
and got the following (as opposed to previous post I got the list by printing the components in importer.py script):

input
conv2d0_w
conv2d0_b
conv2d1_w
conv2d1_b
conv2d2_w
conv2d2_b
...
nn1
nn1/reshape/shape
nn1/reshape
softmax1_pre_activation/matmul
softmax1_pre_activation
softmax1
avgpool0/reshape/shape
avgpool0/reshape
softmax2_pre_activation/matmul
softmax2_pre_activation
softmax2
output
output1
output2

When I previously set BOTTLENECK_TENSOR_NAME to 'pool3/_reshape', it threw an error (non existing node). I am not sure why the component names above don't match node names. Anyway, now I tried to set BOTTLENECK_TENSOR_NAME to 'avgpool0/reshape:0' and both JPEG_INPUT_TENSOR_NAME and RESIZED_INPUT_TENSOR_NAME to 'input' although I guess it doesn't make sense to point to same node.

I tried to modify BOTTLENECK_TENSOR_SIZE value to avoid shape incompatibility error but haven't found the right value.

Regarding your previous answer... does the fact that inception v1 doesn't have DecodeJpeg node mean that the input images have to be transformed into some other format before feeding them into graph? 

Thanks for help again. I really hope to find the way to retrain this model and share the solution with the community.
Message has been deleted

hugo...@gmail.com

unread,
Jun 19, 2017, 1:26:24 PM6/19/17
to Discuss
Hi Niko, I am wondering if you have successfully retrained 5h in the end. If not, what did you do in the end? did you find another 'easier to train' model?  

Thanks, hope you have a nice day
Reply all
Reply to author
Forward
0 new messages