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.

TensorFlow, PyTorch and Keras - deep learning library comparison
John Bowman
John Bowman Owner / AI Developer
Unit 6 5 April 2026 7 min read
menu_book In this lesson expand_more
  1. What each library is and who made it
  2. How Keras relates to TensorFlow
  3. Practical differences for a beginner
  4. How the landscape has shifted
  5. Which one to learn first

Listen to this lesson
0:00
0:00

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?

Deep Dive Podcast

TensorFlow, PyTorch and Keras

Created with Google NotebookLM · AI-generated audio overview

0:00 0:00
Frequently Asked Questions

What is the difference between TensorFlow, PyTorch and Keras?

TensorFlow is a deep learning framework built by Google, released in 2015. PyTorch is a competing framework built by Meta, released in 2016. Keras is not a separate library - it is the official high-level API for TensorFlow, integrated in 2019. So the real choice is between TensorFlow (using Keras as the interface) and PyTorch.

Should I learn PyTorch or TensorFlow first?

Learn PyTorch first. It teaches the actual mechanics better because you write more explicitly - including your own training loops. PyTorch's eager execution is easier to debug. The job market increasingly asks for PyTorch. Once you know PyTorch, TensorFlow is straightforward to pick up.

What is Keras and is it still worth learning?

Keras is the high-level API that ships with TensorFlow. It lets you define models with simple commands like model.add() and model.fit(). It is still widely used, especially for teaching and for standard tasks like image classification. Most beginners who use TensorFlow are actually using Keras without realising it.

Why has PyTorch become more popular than TensorFlow?

PyTorch is more intuitive for people who think like programmers. It uses eager execution by default, meaning operations run immediately and you can print intermediate values. Research papers now cite PyTorch more than TensorFlow. As researchers build in PyTorch, production teams follow because it simplifies the research-to-deployment pipeline.

How It Works

Both TensorFlow and PyTorch work by defining tensors (multi-dimensional arrays) and operations on them. When you build a neural network, you're defining a sequence of mathematical operations that transform inputs into outputs. Both libraries track these operations so they can compute gradients automatically - this is called automatic differentiation or autograd.

TensorFlow originally used a static computation graph: you defined the graph first, then ran data through it. PyTorch uses dynamic graphs (eager execution) by default - the graph is built as operations execute. This makes PyTorch easier to debug and experiment with.

Keras adds a layer of abstraction. Instead of defining individual operations, you stack pre-built layers. A Dense layer, a Conv2D layer, a pooling layer - each is a reusable component. Keras handles the wiring between them and provides sensible defaults so you can get a working model quickly without writing every detail yourself.

Key Points
  • Keras is not a standalone library - since 2019 it is TensorFlow's official high-level API
  • The real choice is between TensorFlow (with Keras) and PyTorch - both are mature, production-ready frameworks
  • PyTorch now dominates research; new papers are more likely to use PyTorch than TensorFlow
  • PyTorch uses eager execution by default, making it easier to debug intermediate values
  • Keras is faster to get working for standard tasks - define, compile, fit - but hides what's happening underneath
  • Learning PyTorch first gives you a stronger foundation; picking up TensorFlow afterwards is easier than the reverse
Sources