# Keras import from trained model

**URL:** <https://community.konduit.ai/t/keras-import-from-trained-model/720>\
**Category:** DL4J\
**Created:** [July 10, 2020, 3:25pm UTC](https://community.konduit.ai/t/keras-import-from-trained-model/720 "2020-07-10T15:25:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elotter](https://avatars.discourse-cdn.com/v4/letter/e/bbe5ce/32.png) [@elotter](https://community.konduit.ai/u/elotter)\
**Post date:** [July 10, 2020, 3:25pm UTC](https://community.konduit.ai/t/keras-import-from-trained-model/720/1 "2020-07-10T15:25:30Z")

</div>

Hi All, just getting started, and trying to import a model so that I can just do evaluations of it in the Java side. I’ve not been directly involved in training of the model, but given the keras model, I suppose I can consider this as a black box.

I’m just trying to read using the following:

String modelFile = “/home/ernest/Desktop/Test/Model\_slideWin\_S2048”;  
Path modelPath = Paths.get(modelFile);

```
    System.err.println("reading model");
    byte[] bytes = Files.readAllBytes(modelPath);

    System.err.println("parsing model");
    ComputationGraph cg = null;
    try (InputStream modelInputStream = new ByteArrayInputStream(bytes)) {
        cg = KerasModelImport.importKerasModelAndWeights(modelInputStream);
    }

    System.err.println("read model");

```

but getting results:

reading model  
parsing model  
SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.  
SLF4J: Defaulting to no-operation (NOP) logger implementation  
SLF4J: See [SLF4J Error Codes](http://www.slf4j.org/codes.html#StaticLoggerBinder) for further details.  
Exception in thread “main” java.lang.ExceptionInInitializerError  
at org.deeplearning4j.nn.modelimport.keras.Hdf5Archive.readDataSet(Hdf5Archive.java:300)  
at org.deeplearning4j.nn.modelimport.keras.Hdf5Archive.readDataSet(Hdf5Archive.java:114)  
at org.deeplearning4j.nn.mod

---

<div class="post-metadata">

**Author:** ![elotter](https://avatars.discourse-cdn.com/v4/letter/e/bbe5ce/32.png) [@elotter](https://community.konduit.ai/u/elotter)\
**Post date:** [July 10, 2020, 3:26pm UTC](https://community.konduit.ai/t/keras-import-from-trained-model/720/2 "2020-07-10T15:26:52Z")

</div>

The model I’m trying to import is this: [Dropbox - Model\_slideWin\_S2048 - Simplify your life](https://www.dropbox.com/s/rrjccjboz3lb91y/Model_slideWin_S2048?dl=0)
