Recently, I was trying to use Cohen’s Kappa as a metric with Keras. I decided I would use the TensorFlow contrib function that already existed. While trying to get TensorFlow working with Keras, I discovered there were no easily-findable documents describing how to do this. The example from Keras’ blog is a few years old, and wasn’t working anymore. So after figuring out how to get TensorFlow working with Keras, I decided to document it (for the children).
Why use TensorFlow with Keras? TF, particularly the contrib portion, has many functions that are not available within Keras’ backend. Ideally you’d want to use Keras’ backend for things like TF functions, but for creating custom loss functions, metrics, or other custom code, it can be nice to use TF’s codebase.