The rise of Deep Learning as a trend has led to the emergence of many tools and frameworks. Keras is one such tool, developed in order to ease the development and training of deep learning models. Using popular Deep Learning libraries like Theano and TensorFlow directly for creating deep learning models can be quite a challenge. That’s where Keras comes to the rescue. It is a high-level library written in Python that can be used as a wrapper on top of TensorFlow or Theano, to simplify the model training process and to make the models more efficient.
Mr. Sujit Pal, Technology Research Director at Elsevier Labs, has been working with Keras for a while. He is an expert in Semantic Search, Natural Language Processing and Machine Learning. He is also a keen Python enthusiast who has a soft corner for JVM-based languages like Java and Scala. Sujit is an active member of the Keras community, and can often be seen on Quora helping fellow developers with their queries. He also writes about new, cutting-edge technologies on his blog Salmon Run.
As a part of Packt’s Tech Expert Insights series, Sujit discusses the excitement surrounding Keras, and explains why it is his framework of choice for Deep Learning.
1. What made you choose to adopt and use Keras in your projects?
My first deep learning toolkit was actually Caffe, then TensorFlow, both for work related projects. I learned Keras for a personal project and I was impressed by the Goldilocks (i.e. just right) quality of the abstraction. Thinking at the layer level was far more convenient than having to think in terms of matrix multiplication that TensorFlow makes you do, and at the same time I liked the control I got from using a programming language (Python) as opposed to using JSON in Caffe. I’ve used Keras for multiple projects now.
2. How has this experience been different from other frameworks and tools? What problems does it solve exclusively?
I think Keras has the right combination of simplicity and power. In addition, it allows you to run against either TensorFlow or Theano backends. I understand that it is being extended to support two other backends – CNTK and MXNet. The documentation on the Keras site is extremely good and the API itself (both the Sequential and Functional ones) are very intuitive. I personally took to it like a fish to water, and I have heard from quite a few other people that their experiences were very similar.
3. What are the prerequisites to learning Keras? And what aspects are tricky to learn?
I think you need to know some basic Python and have some idea about Neural Networks. I started with Neural Networks from the Google/edX course taught by Vincent Van Houke. It’s pretty basic (and taught using TensorFlow) but you can start building networks with Keras even with that kind of basic background. Also, if you have used numpy or scikit-learn, some of the API is easier to pick up because of the similarities.
I think the one aspect I have had a few problems with is building custom layers. While there is some documentation that is just enough to get you started, I think Keras would be usable in many more situations if the documentation for the custom layers was better, maybe more in line with the rest of Keras. Things like how to signal that a layer supports masking or multiple tensors, debugging layers, etc.
4. For what purpose in data science do you use it in your day-to-day programming?
I have spent most of last year working with Image classification and similarity, and I’ve used Keras to build most of my more recent models. This year I am hoping to do some work with NLP as it relates to images, such as generating image captions, etc. On the personal projects side, I have used Keras for building question answering and disease prediction models, both with data from Kaggle competitions.
5. As a developer, what do you think are the areas of development for Keras as a library? Where do you struggle the most?
As I mentioned before, the Keras API is quite comprehensive and most of the time Keras is all you need to build networks, but occasionally you do hit its limits. So I think the biggest area of Keras that could be improved would be extensibility, using its backend interface. Another thing I am excited about is the contrib.keras package in TensorFlow, I think it might open up even more opportunity for customization, or at least the potential to maybe mix and match TensorFlow with Keras.
If Keras has piqued your interest or if you simply want to get started with Deep Learning, a good starting point is Sujit Pal’s co-written book Deep Learning with Keras.