Keras has a nice way to import/export models and weights in json/yaml format : https://keras.io/models/about-keras-models/#about-keras-models
I think interoperability is one of the biggest missing feature in NN libraries at the moment.
I really would like to be able to design/train/tweak new models on keras and be able to do prediction in Java (inside ImageJ/Fiji in my case).
What do you think ?
This is actually a project we're working on with the Keras team! You should expect to see something in September.
Wow that is really awesome !
I let this open until you made the announcement.
@hadim it stated in the link that JSON/YAML format only contain the architecture not the weight
Note that the representation does not include the weights, only the architecture. You can reinstantiate the same model (with reinitialized weights) from the JSON string
The weights are in a separate HDF5 file.
@hadim I'm working on this as we speak. As of v1.1.0, keras models now have save_model and load_model methods which store both model configuration AND weights in a single HDF5 archive. Configurations (model and training) are saved as JSON strings, while weights are stored as NDarrays. So broadly speaking, we are adding functionality to read a Keras HDF5 model archive, instantiate the model described in the config, and load the stored weights. I think we'll have basic functionality for a narrow class of models ready pretty soon.
@turambar Thanks for working on it. Ability to import HDF5 model would be very useful. Any idea when we would have it available?
@suyashps Available now in very early WIP form. Please see the the model_loading branch of deeplearning4j: https://github.com/deeplearning4j/deeplearning4j/tree/model_loading
We do not vouch for correctness at this time. Definitely loading convolutional layers is iffy -- we need to test that we're getting the dimension ordering correct (since Theano and TensorFlow do things differently).
Happy to hear feedback, critiques, etc. Rough roadmap:
Done.
@agibsonccc Thanks for the update. Does it support graph structures now? Can I import models such as Inception?
@crockpotveggies is running inception with dl4j.
You can see a working example of Inception here in a PR on the model zoo for your reference: https://github.com/deeplearning4j/dl4j-model-z/pull/6
@suyashps DL4J supports inception but model import does not cover it yet. Feel free to file an issue and I'll put it on my queue. Alternatively, if you want to take a stab, I'm happy to support you. It should be relatively straightforward!
Thanks @crockpotveggies I'll take a look. As an alternative way I am thinking of defining Inception model in DL4J and then coming up with a way to import weights from Keras trained model.
@turambar Issue created https://github.com/deeplearning4j/deeplearning4j/issues/2362
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
This is actually a project we're working on with the Keras team! You should expect to see something in September.