Search code examples
javamavendeeplearning4jdl4j

ExceptionInInitializerError when running simple DL4J code


I'm currently trying to get dl4j (deeplearning4j) to import my model that I trained in keras 1.2.

This is my code:

public static void main( String[] args )
{
    try {
        MultiLayerNetwork network = KerasModelImport.importKerasSequentialModelAndWeights(
                "C:\\Users\\A\\Documents\\GitHub\\DevanagriRecognizer\\model_keras1.h5");
        System.out.println( "Hello World!" );
    } catch (IOException e) {
        e.printStackTrace();
    } catch (InvalidKerasConfigurationException e) {
        e.printStackTrace();
    } catch (UnsupportedKerasConfigurationException e) {
        e.printStackTrace();
    }
}

I'm using Maven to handle the dependencies, and this is my first time using it. (That might be relevant)

When I run the above code I get a ExceptionInInitializerError caused by UnsatisfiedLinkError: no jnind4jcpu in java.library.path.

It looks like a missing dependency, but I have no idea how to fix it.

This is my pom.xml: https://pastebin.com/FzAMwA0z

And this is my full stacktrace: https://pastebin.com/a2kyUtch

By the way, I'm using IntelliJ with Java 1.8u101 on 64-bit Windows 10


Solution

  • For some reason, changing dl4j.version from 0.8.1-SNAPSHOT to 0.8.0 fixed it. Still not sure why, but it's working.