Live data from Hacker News

Keras Core: Keras for TensorFlow, Jax, and PyTorch

keras.io

21–30 of 73 posts

Re: Keras Core: Keras for TensorFlow, Jax, and PyTorch

#21

Earlier quoted context omitted.

Yes, model weights saved with Keras Core are backend-agnostic. You can train a model in one backend and reload it in another. Coral TPU could be used with Keras Core, but via the TensorFlow backend only.

Super cool, does that mean if someone trains something using the PyTorch backend, I can still use it with the coral if I load the weights using the tensorflow backend?

That's right, if the model is backend-agnostic you can train it with a PyTorch training loop and then reload it and use it with TF ecosystem tools, like serve it with TF-Serving or export it to Coral TPU.

Re: Keras Core: Keras for TensorFlow, Jax, and PyTorch

#24

I worked on the project, happy to answer any questions!

Hi, first off thank you for your contributions, and this goes to the entire team. Keras is a wonderful tool and this was definitely the right move to do. No other package nails the “progressive disclosure” philosophy like Keras.

This caught my eye:

> “Right now, we use tf.nest (a Python data structure processing utility) extensively across the codebase, which requires the TensorFlow package. In the near future, we intend to turn tf.nest into a standalone package, so that you could use Keras Core without installing TensorFlow.”

I recently migrated a TF project to PyTorch (would have been great to have keras_core at the time) and used torch.nested. Could this not be an option?

A second question. For “customizing what happens in fit()”. Must this be written in either TF/PyTorch/Jax only, or can this be done with keras_core.ops, similar to the example shown for custom components? The idea would be you can reuse the same training loop logic across frameworks, like for custom components.

Re: Keras Core: Keras for TensorFlow, Jax, and PyTorch

#26
post #16

If I want to use this brave new keras with torch.compile, what does that look like?

We are still working on this feature. We try to have it in model.compile(jit_compile=True). https://github.com/keras-team/keras-core/blob/v0.1.0/keras_c...

Wait so what happens if I use a model with torch backend now and call .compile()? Does it just return and then do normal torch jit when .fit() (or whatever the keras notation is, i have forgotten most of it) is called?

Re: Keras Core: Keras for TensorFlow, Jax, and PyTorch

#28
post #11

Earlier quoted context omitted.

> What's different now ? PyTorch adoption: back when Keras went hard into TensorFlow in 2018, both TF and PyTorch adoption were about the same with TF having a bit more popularity. Now, most of the papers and models released are PyTorch-first.

Yes I understand why they do the move (they want to attract pytorch user). What's the benefit for the user instead of directly using pytorch for example ? I see we can maybe use tpu by switching to jax etc... PS: sorry I'm a bit salty by my user experience of Keras.

Pytorch is an animal by itself when you try to put it into production. They have started addressing it with torch 2.0 but it still has lengths to go. With this you can switch to TFserve if you have usual architecture.

Re: Keras Core: Keras for TensorFlow, Jax, and PyTorch

#29

I worked on the project, happy to answer any questions!

How does the future look for TFLite and Edge AI/TinyML in general?

Will Keras Core support direct deployment to edge devices like RPi or Arduino?

Will the experience of defining and training a model in JAX/PyTorch and then deploying to edge devices be seamless?

Anything related on the roadmap?

Re: Keras Core: Keras for TensorFlow, Jax, and PyTorch

#30
post #16

If I want to use this brave new keras with torch.compile, what does that look like?

We are still working on this feature. We try to have it in model.compile(jit_compile=True). https://github.com/keras-team/keras-core/blob/v0.1.0/keras_c...

A lot of this seems like abstraction for abstractions sake. When would someone actually use this?
Post reply on HN