TensorFlow, PyTorch and Keras: Which Deep Learning Library Should You Learn?
These three libraries don't compete equally. Keras isn't even a separate choice anymore - it's part of TensorFlow. And PyTorch is winning with researchers. But which one should you actually learn first? That's where it gets interesting.
menu_book In this lesson expand_more
Most deep learning courses list TensorFlow, PyTorch and Keras as if they're three separate options you need to pick between. That's not quite right. Understanding what each one actually is makes the choice much clearer.
What Each Library Is and Who Made It
TensorFlow was built by Google and released in 2015. It's a framework for building and training neural networks. It handles the maths operations - matrix multiplication, backpropagation and so on - efficiently, runs on CPUs or GPUs, and lets you define networks in Python.
PyTorch was built by Meta (formerly Facebook) and released in 2016. It does the same job as TensorFlow but with a different philosophy. It's more Pythonic, more dynamic, and generally feels less clunky if you know Python.
Keras was originally a separate library by François Chollet, built on top of TensorFlow. In 2019, Google integrated it into TensorFlow as the official high-level API. Now Keras is just "how you use TensorFlow nicely" rather than a separate library.
So really, you're choosing between TensorFlow (with Keras as the interface) and PyTorch.
How Keras Relates to TensorFlow
Keras is the simple, friendly way to use TensorFlow. You write code like model.add(Dense(128)) and model.compile(optimizer='adam', loss='categorical_crossentropy') and it handles the complexity underneath.
TensorFlow is the full framework. If you need more control, you can drop down and write custom operations, manage computational graphs directly, and do things Keras doesn't expose. Most beginners will never need that lower level.
So when you hear "learn TensorFlow," it mostly means "learn the Keras API that ships with TensorFlow."
The Practical Differences for a Beginner
PyTorch feels more like writing Python. Operations happen immediately - eager execution by default. If you write x = some_tensor * 2, you get a result right then. This is good for debugging because you can print intermediate values and see what's happening at each step.
TensorFlow with Keras is simpler for standard tasks. You define a model, compile it, and fit it to data. There's more abstraction, which means less control but also less boilerplate. For image classification or basic text tasks, Keras is faster to get working.
PyTorch requires more explicit thinking. You often write training loops by hand - more verbose, but it gives you more control and teaches you what's actually happening.
For a beginner trying to classify handwritten digits or build a basic image classifier, Keras is fine. You'll learn the core concepts faster because there's less scaffolding to write. If you want to understand what's happening at every step, PyTorch's explicit loops will teach you more.
How the Landscape Has Shifted
Five years ago, TensorFlow dominated. Every serious ML job used it. Every course taught it.
Now PyTorch dominates in research and increasingly in production at major companies. Researchers prefer PyTorch because it's easier to prototype with. Production teams increasingly follow because, if all your researchers are building in PyTorch, it makes sense to keep that consistent.
TensorFlow is still widely used - it hasn't disappeared - but it's lost the assumed dominance. Last I checked, new research papers were more likely to use PyTorch than TensorFlow. This shift happened because PyTorch is genuinely nicer to use. It's not that TensorFlow is bad; PyTorch is just more intuitive for people who think like programmers rather than dataflow engineers.
Which One to Learn First and Why
Learn PyTorch.
PyTorch teaches you the actual mechanics better because you have to write more explicitly. You'll understand backpropagation better if you write your own training loop instead of calling model.fit(). You'll understand gradients better if you compute them yourself.
The job market increasingly asks for PyTorch. If you learn PyTorch first, picking up TensorFlow later is just "oh, this does the same thing with more abstraction." The reverse is harder - if you've only used Keras, PyTorch's approach feels more unfamiliar.
PyTorch's eager execution is also better for debugging while learning. You'll get less confused by mysterious behaviour you can't inspect.
The downside: PyTorch is slightly more verbose. You'll write more code to accomplish the same thing. But that's actually good for learning - it forces you to think about what each step is doing.
If you're in a job that requires TensorFlow, or want to learn Keras's high-level API first and worry about backpropagation later, that's a valid choice. But starting from scratch and wanting to actually understand what's happening? PyTorch first, TensorFlow second.
Check your understanding
2 questions — select an answer then check it
Question 1 of 2
What happened to Keras in 2019 that changed how it relates to TensorFlow?
Question 2 of 2
Why does the lesson recommend learning PyTorch before TensorFlow?
