Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Transfer Learning of a working TensorFlow network

Hi Everyone,

I am trying to build a custom Tensorflow image classifier so I have been following the tutorial at
The custom classifier applies transfer learning to the imagenet network so that it can classify images which I have trained it to classify. At the end of the tutorial my custom Tensorflow image classifier is working, and all I need to do now is compile it with mvNCCompile so that I can run it with the NCS.
According to this link I see that I need to have the input node name and output node names when I use mvNCCompile. At the end of the tutorial however, I only have a "retrained_graph.pb" and classes.txt. After looking at the sample code on the Movidius Tensorflow page, I still don't know how to use mvnCCompile on my retrained_graph.pb.

If I just run "mvNCCompile retrained_graph.pb" I get an error: KeyError: "The name 'input:0' refers to a Tensor which does not exist. The operation, 'input', does not exist in the graph."
So I figured I would need to supply the command with the proper input node name and output node name but I don't know how to get those from just a "retrained_graph.pb" file.

It would be awesome if someone could guide me to compiling a graph.pb file with mvNCCompile.



  • 5 Comments sorted by Votes Date Added
  • edited November 2017 Vote Up1Vote Down

    Sorry for the lengthy update (Now I'm getting [Error 5] Toolkit Error: Stage Details Not Suported: PlaceholderWithDefault):

    I troubleshooted further and suspected the problem to be in the (in usr/local/bin/ncsdk/Controllers) program. Around line 185 when the program is trying to read the .pb file, I don't think it is reading it correctly. When I copied the existing code to another program and tried to print out the list of Tensors in the graph, it showed none, but if I read in the graph differently, I do get the Tensors.

    Problem though is that now when I run mvNCCompile retrained_graph.pb -in=input -on=final_result, the error I get is

    /usr/local/lib/python3.5/dist-packages/tensorflow/python/util/ DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() instead
    if d.decorator_argspec is not None), _inspect.getargspec(target))#
    [Error 5] Toolkit Error: Stage Details Not Supported: PlaceholderWithDefault

    The code I had changed in TensorFlowParser was (note I only made it work for .pb files because that is relevant to my project):

    instead of:
    filetype = path.split(".")[-1]
    if filetype == 'pb':
    graph_def = graph_pb2.GraphDef()
    with open(path, 'rb') as f:
    saver = tf.train.import_meta_graph(path)
    if saver is not None:
    saver.restore(sess, path[:path.rfind('.')])

    I did:

    with tf.gfile.FastGFile(path, 'rb') as f:
    (tab)graph_def = tf.GraphDef()
    (tab)_ = tf.import_graph_def(graph_def, name='')

    with tf.Session() as sess:

    and then immediately after (nested inside the sess) where graph is initialized I set it to

    (tab)graph = sess.graph

    After this it seems like it succeeds when it finds the input tensor by name (and maybe the output tensor as well).

    It would be really helpful if someone could troubleshoot and tell me why I am getting the Error 5 Toolkit Error

  • hi, i have the same problem. please hurry with this

  • I have the same issue and can confirm that the fix provided by kartik924 solves this problem!

  • Though kartik924's solution fix this problem, there is no need to change the SDK code.
    The input node name searching failed, because tensorflow added an 'import' prefix by the tf.import_graph_def.
    So when compiling, just add the "import"prefix as follows:
    mvNCCompile -s 12 inception_v3_2016_08_28_frozen.pb -in=import/input -on=import/InceptionV3/Predictions/Reshape_1

  • @Zhebin Hi but I can only get a output file with a 45kb size, and totally unusable since it seems store no values at all.
    How do you get your inception_v3_2016_08_28_frozen.pb? I just use the retrained_graph.pb from tensorflow's . Did you use any graph_transform tools on your frozen model?

Sign In or Register to comment.