{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/CNTK/issues/1050","repository_url":"https://api.github.com/repos/Microsoft/CNTK","labels_url":"https://api.github.com/repos/Microsoft/CNTK/issues/1050/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/CNTK/issues/1050/comments","events_url":"https://api.github.com/repos/Microsoft/CNTK/issues/1050/events","html_url":"https://github.com/Microsoft/CNTK/issues/1050","id":189841544,"number":1050,"title":"Evaluating models created using python bindings in C# ","user":{"login":"Troelsj","id":3653067,"avatar_url":"https://avatars.githubusercontent.com/u/3653067?v=3","gravatar_id":"","url":"https://api.github.com/users/Troelsj","html_url":"https://github.com/Troelsj","followers_url":"https://api.github.com/users/Troelsj/followers","following_url":"https://api.github.com/users/Troelsj/following{/other_user}","gists_url":"https://api.github.com/users/Troelsj/gists{/gist_id}","starred_url":"https://api.github.com/users/Troelsj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Troelsj/subscriptions","organizations_url":"https://api.github.com/users/Troelsj/orgs","repos_url":"https://api.github.com/users/Troelsj/repos","events_url":"https://api.github.com/users/Troelsj/events{/privacy}","received_events_url":"https://api.github.com/users/Troelsj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-11-16T20:54:26Z","updated_at":"2016-11-24T18:15:07Z","closed_at":null,"body":"Hi,\r\n\r\nI have a problem with evaluating models, created using the python bindings, through the C# evaluation interface.\r\n\r\nIf I follow the examples on saving a model it would look like:\r\n``python \r\n        persist.save_model(z, os.path.join(model_path, network_name + \"_{}.dnn\".format(epoch)))\r\n``\r\n\r\nIf I then load that model into a C# program in order to classify an image, it returns the error:\r\n\r\n> No Output nodes found: Cannot determine Input node dimensions due to lack of Output nodes.\r\n(are 'outputNodeNames' and/or 'OutputNodes' properly defined in the configuration file?)\r\n\r\n(Both with my own models and the models from the examples)\r\nWhich seems like a simple error, but I can't find any explanation on how this should be defined in python, it works fine if I load a brainscript model into the program.\r\n\r\nUsing the python evaluation function works with the python model, something like:\r\n\r\n``python\r\nmodel = load_model(\"model.bin\")\r\ninput_arg = model.arguments\r\ntest_image  = np.array(Image.open(\"image.png\"), dtype = np.float32).T\r\nresults = np.squeeze(model.eval({ input_arg:test_image }))\r\n``\r\n\r\nBut that doesn't work with a brainscript model, even if I change it to fit the extra inputs.\r\n\r\nSo are the models really not created equally, why is the resnet20 model created in python not the same as the one created in brainscript? \r\nIs there an easy way of defining outputnodes using the python bindings, such that it works with a C# evaluation program?\r\n\r\nI am running cntk v2.0 beta3, built from source for GPU usage."},"comment":{"url":"https://api.github.com/repos/Microsoft/CNTK/issues/comments/262827837","html_url":"https://github.com/Microsoft/CNTK/issues/1050#issuecomment-262827837","issue_url":"https://api.github.com/repos/Microsoft/CNTK/issues/1050","id":262827837,"user":{"login":"Troelsj","id":3653067,"avatar_url":"https://avatars.githubusercontent.com/u/3653067?v=3","gravatar_id":"","url":"https://api.github.com/users/Troelsj","html_url":"https://github.com/Troelsj","followers_url":"https://api.github.com/users/Troelsj/followers","following_url":"https://api.github.com/users/Troelsj/following{/other_user}","gists_url":"https://api.github.com/users/Troelsj/gists{/gist_id}","starred_url":"https://api.github.com/users/Troelsj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Troelsj/subscriptions","organizations_url":"https://api.github.com/users/Troelsj/orgs","repos_url":"https://api.github.com/users/Troelsj/repos","events_url":"https://api.github.com/users/Troelsj/events{/privacy}","received_events_url":"https://api.github.com/users/Troelsj/received_events","type":"User","site_admin":false},"created_at":"2016-11-24T18:15:07Z","updated_at":"2016-11-24T18:15:07Z","body":"@zhouwangzw  Okay, that seems to work, is there any plans to make it more streamlined further on?\r\n\r\nSo I load the model as:\r\n\r\n>var model = new ModelEvaluationExtendedF();\r\n>var networkConfiguration = \"outputNodeNames=__v2libuid__Plus2023__v2libname__Plus2014\\n traceLevel=1\\n deviceId=0\\n modelPath=\" + modelFile + \"\";\r\n>\r\n>model.CreateNetwork(networkConfiguration);\r\n\r\n\r\nAnd evaluate it as:\r\n\r\n\r\n>VariableSchema inputSchema = model.GetInputSchema();\r\n>VariableSchema outputSchema = model.GetOutputSchema();\r\n>\r\n>model.StartForwardEvaluation(outputSchema.Select(s => s.Name).ToList<string>());\r\n>\r\n>var inputBuffer = inputSchema.CreateBuffers<float>();\r\n>var outputBuffer = outputSchema.CreateBuffers<float>();\r\n>\r\n>int inDims = inputSchema.CreateBuffers<float>()[0].Size;\r\n>for (int i = 0; i < inDims ; i++ )\r\n>{\r\n>        inputBuffer[0].Buffer[i] = resizedCHW[i];\r\n>}\r\n>\r\n>model.ForwardPass(inputBuffer, outputBuffer);\r\n>var decision = outputBuffer[0].Buffer;\r\n\r\n\r\nI guess that is the correct approach then? Though there probably is a more efficient way of making the image the inputBuffer. \r\n\r\nBut otherwise it seems to work, thank you very much for your help :)\r\n"}}
{"actor":{"display_login":"Troelsj"}}