Cntk: Loading a ONNX model with CNTK Java

Created on 4 Jun 2018  路  5Comments  路  Source: microsoft/CNTK

Hi everyone,

I am trying to load a ONNX model with the CNTK java api and I am getting the following error.

Exception in thread "main" java.lang.RuntimeException: Failed to load the model.

[CALL STACK]
    > CNTK::TrainingParameterSchedule<unsigned __int64>::  GetMinibatchSize
    - CNTK::  XavierInitializer
    - CNTK::Function::  Load
    - Java_com_microsoft_CNTK_CNTKLibJNI_Function_1load_1_1SWIG_10
    - 0000000002E17F74 (SymFromAddr() error: The specified module could not be found.)


    at com.microsoft.CNTK.CNTKLibJNI.Function_load__SWIG_0(Native Method)
    at com.microsoft.CNTK.Function.load(Function.java:244)
    at Main.main(Main.java:8)

Process finished with exit code 1

Here is my Java class;

import com.microsoft.CNTK.DeviceDescriptor;
import com.microsoft.CNTK.Function;
import com.microsoft.CNTK.ModelFormat;

public class Main {

    public static void main(String[] args) {
        Function function = Function.load("../res/model.onnx", DeviceDescriptor.getCPUDevice(), ModelFormat.ONNX);
        System.out.println(function);

    }
}

Any input about why this error is caused is greatly appreciated. :)

All 5 comments

Can you load the same model in Python? And which version of CNTK is this?

@KeDengMS : Thanks much for the reply. I am using the CNTK version 2.5.1 for Windows + Linux; the CPU only version. Now, I am not sure whether it works in Python since I didn't try it with Python. I created this simple model (which basically classifies some animals) using the Microsoft Custom Vision (https://customvision.ai/) tool and downloaded it as a ONNX file.

Is it possible to share the model?

@KeDengMS : No problem. It's just a simple test model. Let me attach it here for you. Thanks so much :)

You'll find the file within this zip.

servicelink.zip

Seems it uses legacy padding op that's not supported in CNTK yet.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pallashadow picture pallashadow  路  5Comments

haixpham picture haixpham  路  5Comments

springkim picture springkim  路  4Comments

mogrysama picture mogrysama  路  4Comments

chrispugmire picture chrispugmire  路  3Comments