Search code examples
c#cntk

Unhandled exception loading a valid model in CNTK


I've been training some models iteratively with CNTK, replacing the data after every iteration with a new set and then running another round of training sessions. The .DNN files load fine in both CNTK itself (running the Train command), as well as using CPU evaluation from C# using the Microsoft.Research.CNTK.CpuEval-mkl nuget package.

Evaluation of the model is now taking long enough that I decided to switch over to the GPU library for C#, CNTK.GPU. When trying to load the model in my code, however, I get the following exception:

Prediction output operand's shape [7 x 1] is incompatible with label operand's shap [7] for the CrossEntropyWithSoftmax operation
at CNTK.Function.LoadModel(String modelFile)

Any idea how to get the model to load? If I have to change the CNTK file to update the topology I can do so, but I'd hate to throw out the progress I've made with the current models.

Edit: Here is the section of the CNTK file I used to build the network. I essentially took some example code and changed it to fit what I needed.

    SimpleNetworkBuilder = {
    layerSizes=84:5000*5:7
    trainingCriterion="CrossEntropyWithSoftmax"
    evalCriterion="ErrorPrediction"
    layerTypes="RectifiedLinear"
    initValueScale=1.0
    uniformInit=true
    needPrior=true
    addDropoutNodes=true
}

Solution

  • Which CNTK version are you using? This issue should be fixed in the latest Beta12. When you install the Nuget package, please explicitly select the version Beta 12. (The Nuget package manager does not show Beta12 as the latest version, since it uses string comparison for version check.) Please try with Beta 12. And let us know if you still have the problem.