-1

I have been working with neural networks in Deeplearning4j and needed to switch it to Python. To use the same model (MultiLayerNetwork in DL4J) I saved it as a .h5 file. Like this:

File newFile = new File("newModel.h5");
ModelSerializer.writeModel(network, newFile, true);

Now, when i try to load it in Python I get the following error:

OSError: SavedModel file does not exist at: newModel.h5/{saved_model.pbtxt|saved_model.pb}

I have tried to use different extensions like .pb and used relative and absolute paths in python. Nothing helped. Can anyone explain to me why this happens? There seems to be not enough information on this issue on the internet and it seems to be the only way to implement the same code in python is to train a new model, etc.

art-m
  • 9
  • 5

1 Answers1

0

a dl4j model is a zip file. Could you clarify what you're trying to do? If you imported it from keras and need to resave it, the best you can do is export the weights as a numpy array and recreate the architecutre. You can do that with model.params() which gives you the weights.

Adam Gibson
  • 3,055
  • 1
  • 10
  • 12