Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

TensorFlow, Keras, Theano: Which to Use

DZone's Guide to

TensorFlow, Keras, Theano: Which to Use

I have spent a lot of time lately working with TensorFlow and Keras, but sometimes, it can be difficult to figure out when to use which. Here's how I make that crucial decision.

· AI Zone ·
Free Resource

Insight for I&O leaders on deploying AIOps platforms to enhance performance monitoring today. Read the Guide.

So over the past few months, I've been spending a significant amount of time working with TensorFlow and Keras (with TensorFlow under Keras), and I've been running into the question of when I should use which toolset.

For those of you who haven't worked with Keras yet, it's a Python library designed for easy neural network assembly that comes with a large number of prepackaged network types, ranging from convolutional networks in two- and three- dimensional flavors, to long- and short-term networks, to more general recurrent networks. Building networks using Keras is straight-forward — though determining exactly what network to build isn't. The semantics Keras uses in its API design are very layer-oriented, making network assembly relatively intuitive.

TensorFlow, on the other hand, is arguably more powerful — but doesn't have all the prepackaged networks. Nor does it come packaged with many of the datasets or manipulation utilities that Keras does. It does, however, let you build arbitrarily complex neural architectures.

Remember: Keras is very layer-oriented. Not all networks use strict layering. If we're interested in a design in which some elements skip a given layer to be used in later layers, it becomes a bit complicated to implement in Keras. In TensorFlow, you have more control over the network, and this kind of implementation is easier to implement. If you're using known network designs and combining them in new ways, or applying them to new data, Keras can't be beat. But if you're designing new types of networks, TensorFlow seems like the best choice.

The thing is, though, once you've implemented a new network architecture, being able to reuse that architecture can really make your life easier. And you actually can implement custom layers that pass data to later layers, or do more sophisticated things, too.

So, your best bet? Use both. Use Keras when you're implementing known architectures against new data and TensorFlow when implementing new models. When finished with the TensorFlow models, port to Keras and add to your personal library (or even better, the Keras project). This way, you can focus on the other things you need to take care of when building these kinds of systems: formatting the input data, evaluating results, tuning hyperparameters, that kind of thing. This approach works for Theano, too, as well as any other deep learning framework you're fond of.

This is the kind of thing I've done: I've used TensorFlow for prototyping and then built the final models using Keras and Keras primitives for portability. This way, I get the best of both worlds. Do this, and you will, too.

TrueSight is an AIOps platform, powered by machine learning and analytics, that elevates IT operations to address multi-cloud complexity and the speed of digital transformation.

Topics:
ai ,keras ,tensorflow ,deep learning ,theano

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}