tensorflow / java

Java bindings for TensorFlow
Apache License 2.0
823 stars 201 forks source link

What happened to the tensorflow.keras package? #217

Open demongolem opened 3 years ago

demongolem commented 3 years ago

Please make sure that this is a feature request. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:feature_template

System information

TF 2.3.1 Yes, if able

Describe the feature and the current behavior/state.

There used to be a separate repo tensorflow-keras. That page said the worked got merged into this. Yet, I don't see a org.tensorflow.keras package and my ide complains when I try to access stuff from it. I want to be able to, at a minimum, load models from Keras. But yes, it would also be nice to create models on the Java side as well.

Will this change the current api? How? I suppose so because I do not see a org.tensorflow.keras package currently.

Who will benefit with this feature? Everyone who is already familiar with Keras. But also those newer to deep learning as well because Keras is higher level and easier to use than vanilla tensorflow.

Any Other info. If there have been massive conversations and decisions made behind the scenes, I would hope that at least the README.md is updated to say the level of support, if any, for Keras and why that decision was made so that people aren't scratching their heads.

Craigacp commented 3 years ago

We looked into making something that was bug compatible with Keras, and that's tricky to do given the differences between Python and Java. Mirroring the Python API into Java would have ended up with something that wasn't very Java-like (and would have improperly encapsulated it's internals).

We're working on a higher level framework modelled after Keras, but it's not called Keras because we thought that would be misleading due to the API differences. It's not all landed in the main tree yet, but @JimClarke5 is working his way through the API and landing it in chunks. You can see the progress here - https://github.com/tensorflow/java/tree/master/tensorflow-framework/src/main/java/org/tensorflow/framework, and there are several active PRs which will integrate more pieces of it.

As for loading Keras models, the Keras hdf5 format is sparsely documented at best, and so we've not started looking at how to load Keras models saved in that format into Java. You can load in TensorFlow SavedModels which we understand to be the format that all of TF is moving towards. Once the API is done we might take another look at loading Keras models.