Is there a property to verify that a model is created.
In the course of building CNTK into my C# project, I felt a need for a property of of a model which says, whether the model is already created or still not. In effect, I've needed to create a wrapper class with this property, but I think that it might be useful in the base classes like IEvaluateModelManagedF and IEvaluateModelManagedD. If there is no way to simply get this, then perhaps this issue may be a development request.
@KolyaIvankov I am not sure I really understand the request. What do you mean whether the model is alread created or not? When CreateNetwork() returns, the model is loaded and ready to use. Currently we only support synchronous call.
Hi @zhouwangzw
Thanks for the prompt reaction and sorry in advance for a lengthy answer.
First of all, the network is basically created in two stages. First, one initializes the instance of an object
IEvaluateModelManagedF model = new IEvaluateModelManagedF();
and then creates a network in this model
model.CreateNetwork(string.Format("modelPath=\"{0}\"", path));
And I make use of this two-step model creation. Here is the deal: I build CNTK into a visual engineering framework. There is a user control wrapping an instance of a network. The network is then uploaded via the interface. The object is designed in such a way that it will allow the user upload other model types (e.g. TensorFlow via the upcoming TensorFlowSharp, since some of my colleagues prefer using it). All this is done to speed up the engineering process.
Now, according to the general philosophy of the framework, the object wrapping the neural network consumes measurements from and provides measurements to another objects on the desktop. The comboboxes on the right hand correspond to the input layers (here is one but there will be as many as the number of input layers the model has). The user then chooses, which measurements of all the objects linked to the NeuroNet object shall serve as inputs.

Every time the model is changed, or a new measurement provider is being linked to the network object, the program refreshes comboboxes and their entries. This requires querying the dictionaries of inputs and outputs from the model.
However, if the model does not exist – I've just put the control on desktop and haven't chosen the file – the operations like
model.GetNodeDimensions(NodeGroup.Input);
just throw exceptions. Yet it is simply more aesthetically pleasant to have a single function for creating and refreshing the user control. A good piece of code could have looked like that
if (model.IsCreated)
{
var ins = model.GetNodeDimensions(NodeGroup.Input);
[Create and fill comboboxes]
}
else
{
[Create empty list of comboboxes]
}
Currently I solve this problem by wrapping a model in another class possessing a field isCreated and a property IsCreated. But to me it seems just more logical to have such a property built into the IEvaluateModelManagedF in CNTK. Just a suggestion, not much more.
@KolyaIvankov Thanks for your explanation! Yes, this feature is not supported by EvalDll API. But we have now a new C# API for model evaluation, which creates the model in one step (LoadModel()), and also provides more new features, like support GPU, support batch evaluations, and model parameter sharing. It supports loading model trained by Brainscript as well as Python. This page describes how to use the API. The examples can be found here , with instructions. I would recommend you to use the new API, as the EvaluateModelmanaged API will be deprecated in future and no new features will be added. Just post here or on StackOverflow (with cntk as tag) if you have any questions when using the new API. Thank you!
@zhouwangzw Thanks, I was too busy working out my own code to follow the new trends in CNTK for a while and still using beta7. StackOverflow was quite silent on the CNTK previously, but I will be using it from now on. Closing the issue.