Are you thinking of getting started in Machine Learning but not sure which framework to learn?
Maybe PyTorch (you clicked on this post after all). But you heard TensorFlow was great too. What about all the other options?
Your time is valuable and with so many options available, you want to know which one is worth learning first and why.
I'm going to spoil it for you but you can't go wrong with either PyTorch or TensorFlow. But now that I said that, I'll bet you that by the end of this post, you'll choose PyTorch 😉.
Only one way to find out I guess, right?
But first...
PyTorch is an open-source Python-based framework for machine learning. This simply means that it's based on the incredibly popular Python programming language, and the Torch ML library.
And because it's open-source, it allows anyone around the world to download and contribute (with adequate checks) to the PyTorch source code, which currently has over 60,000 stars on GitHub.
Due to this popularity, many of the world’s most impressive machine learning and artificial intelligence (AI) models are built using PyTorch, and I'll share some examples in just a second.
Note: By building, I mean, the algorithms are coded in PyTorch and then are used for various tasks such as:
Here you can see an example of artwork created by AI, which has really taken off in recent months.
Chances are if there’s a machine learning task that you can think of, there’s a PyTorch model out there for it.
Note: For simplicity, I use the terms artificial intelligence (AI), machine learning (ML) and deep learning interchangeably. Deep learning is a form of ML and ML is a form of AI. PyTorch is mostly known for deep learning, the form of ML used for many of the latest AI advancements.
Even if we ignore all the possible applications listed above where you can use PyTorch, there are still multiple other reasons to learn and use it.
For starters, it’s a very capable machine learning framework with a unique twist.
Let me explain:
I’m a big fan of the idea that you should learn the language rather than just the framework. In this case, learn the language of machine learning, rather than just a framework for it.
This will give you a deeper understanding and make you much more capable at using the framework you choose.
(Anyone can drill a hole, but putting up a shelf correctly takes more skill than knowing how to use a drill).
So the beautiful unique twist with PyTorch is that you will actually learn the language of machine learning at the exact same time as you're learning to use PyTorch itself.
How?
Well, the main objectives of machine learning are:
Sounds easy?
Sure it does. But those two problems are what some of the best engineers and researchers in the world are working on right now, and the solutions keep changing.
PyTorch helps you build these solutions.
So by learning to use PyTorch for various problems, (like you would in the Zero to Mastery: PyTorch for Deep Learning course) you get to double the bang for your buck.
You’ll be learning machine learning and how to use one of the main tools for machine learning at the same.
Learning machine learning by doing machine learning. Genius right?
How about a few more reasons why you should learn it...
Several of the world’s biggest technology companies such as OpenAI (creators of GPT-3), Microsoft, Amazon, Tesla, Meta (Facebook and Instagram), Airbnb, Apple and many more large companies use PyTorch to power their machine learning products.
What like?
Pretty cool right?
And there’s a trickle-down effect, because if the largest technology companies use PyTorch, many other companies will too. (And have already started).
And the more companies using it, the more jobs there will be available for people that know how to use PyTorch.
Heck, PyTorch is even used in weed-killing tractors!
If machine learning is finding patterns in data and deep learning is finding deep patterns in data, how exactly does it work?
Lots and lots of calculations. Specifically, matrix multiplications.
I won’t get into specifics here but you can see the free matrix multiplication chapter in the PyTorch Fundamentals notebook at learnpytorch.io for more detail.
The important point is that machine learning requires performing mathematical operations at scale. As you can imagine, these operations require computer processing power and some forms of computer processors are faster than others.
Graphics Processing Units (GPUs) or the newer Tensor Processing Units (TPUs) are generally faster than Compute Processing Units (CPUs) at matrix multiplications (the main operation behind many deep learning algorithms).
And the great news is that PyTorch comes with the ability to perform accelerated computations on these devices out of the box.
All with a single line of code:
# Send "thing_you_want_to_GPU" to the GPU ("cuda" is the framework for GPU computing)
thing_you_want_to_GPU = thing_you_want_to_GPU.to("cuda")
Accelerated computing means you can perform machine learning experiments faster, figure out what doesn’t work faster, and in turn, figure out what does work faster.
It’s no surprise PyTorch is so widely used by many of the largest technology companies, especially when you realize that PyTorch is also the most used machine learning research framework.
According to paperswithcode.com (one of the best places to view the latest and greatest in the world of machine learning), as of September 2022, PyTorch is the machine learning framework used for 64% of machine learning research teams who publish their code.
Impressive right?
And just like before with FAANG adoption, if the latest research is being published with PyTorch, then the industry starts to follow and use it also.
For further proof, the use of PyTorch on the popular data science challenge website, Kaggle, has grown year-on-year for the past five years (as reported in their 2022 machine learning and data science survey).
PyTorch originated at Facebook due to a need to process the large amounts of data the company was getting and to help with their ad platforms targeting.
Then in 2017, they open-sourced PyTorch to allow others to benefit from its capabilities. But open-sourcing PyTorch wasn't purely altruistic. It also meant that other talented engineers, outside of Facebook, would also start to work on it.
This means the PyTorch ecosystem today has contributors from various people and industries all over the world.
A handful of examples include:
You can see a full list of the integrations on the PyTorch Ecosystem page.
The most important reason (and because no one likes using tools that suck to work with).
With just a couple of lines of code, PyTorch allows us to do incredibly interesting and fun things that simply weren’t possible 10 years ago even if you had a team of 20 engineers and a year of compute time!
That’s crazy to think about, and PyTorch is only getting better.
If you’ve never done it before, writing machine learning code, especially using PyTorch feels like part art, part science.
Like a Japanese tea ceremony to convince data to reveal its secrets, every experiment brings a surprise.
That’s why I designed the Zero to Mastery: PyTorch for Deep Learning course to be as hands-on as possible.
Inside, you’ll learn important machine learning concepts by writing thousands of lines of PyTorch code:
It's a blast!
Although this article is focused on PyTorch, I’m putting this here because this question comes up a lot, and it might be the last thing that stops you from learning.
So which framework wins the great PyTorch vs. TensorFlow battle?
Maybe I'll do a deep dive into this soon diving into specific use cases for each. But my overall conclusion will still likely be that you can't go wrong picking either one.
The simple answer is what I said before: learning the language of machine learning is more important than the framework you choose.
Both allow you to do this.
They're both great. Flip a coin and pick one. What matters more is that you just get started. You won't regret being part of this incredibly fun industry.
And even better news? No matter which one you choose, we have courses on both!
All you need to do is install, learn and apply!
PyTorch runs on almost any computing system you can think of (Linux, Windows, Mac) and you can install it via the instructions on the PyTorch install page.
However, the quickest way to get started is via Google Colab, a free and online compute environment (the same one we use in the ZTM PyTorch course).
And it's as simple as that!
So what are you waiting for? Go ahead and learn PyTorch today and start building projects of your own.
Who knows... you could be the next ML hire at Tesla.