The Top 4 Reasons to Learn PyTorch (and start getting into AI)
Daniel Bourke
Teaching beginners ML at zerotomastery.io, building ML at nutrify.app
Machine learning and artificial intelligence (AI) are exploding!
And as you'll find out, PyTorch is one of the biggest driving forces behind many of the latest AI revolutions.
So if you're looking to build machine learning and AI-powered systems, chances are you'll eventually be stumbling across PyTorch.?
But before we start with why you should learn PyTorch, let's discuss what it is.
What is PyTorch?
PyTorch ?is an open-source Python-based framework for machine learning.
Open-source means anyone around the world can download or contribute (with adequate checks) to the?PyTorch source code , which currently has over 60,000 stars on GitHub.
Many of the world’s most impressive machine learning and artificial intelligence (AI) models are built using PyTorch.
By building, I mean, the algorithms are coded in PyTorch and then are used for various tasks such as:
And more!
Chances are if there’s a machine learning task you can think of, there’s a PyTorch model out there for it.
Note:?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.
Why PyTorch?
The above is more than enough reason to learn PyTorch.
It’s a very capable machine learning framework.
Note:?In computer programming, a framework is something that provides the scaffolding for various functionality. For example, a machine learning framework like PyTorch provides tools written in Python to perform machine learning tasks.
I’m a big fan of the idea that you should learn the language rather than the framework.
As in, learn the language of machine learning, rather than just the framework for it.
However, the twist is, you can learn the language of machine learning at the same time as learning PyTorch.
How?
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 said solutions.
So by learning to use PyTorch for various problems, such as, in the?Zero to Mastery: PyTorch for Deep Learning course you’ll be gaining skills in machine learning as well as in using one of the main tools for machine learning.
Learning machine learning by doing machine learning.
How about a few more reasons?
1. Several of the biggest technology companies in the world use PyTorch
OpenAI (creators of GPT-3 and ChatGPT), Microsoft, Amazon, Tesla, Meta (Facebook and Instagram), Airbnb, Apple and many more large companies use PyTorch to power their machine learning products.
The computer vision algorithms in Tesla’s self-driving system, Autopilot, are built using PyTorch.
The translation, speech-to-text, feed-curation and voice recognition algorithms inside Facebook and Instagram are created with PyTorch.
And there’s a trickle-down effect.
If the largest technology companies use PyTorch, many other companies will (and do) too.
PyTorch is even used in?weed-killing tractors !
2. PyTorch comes with accelerated computing out of the box
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.
The important point is that machine learning requires performing mathematical operations at scale, these operations require compute 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 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, in turn, figure out what?does?work faster.
领英推荐
3. PyTorch is the top machine learning research framework
It’s no surprise PyTorch is so widely used by many of the largest technology companies.
Because 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.
In essence, 64% of machine learning research teams who publish code with their machine learning research papers use PyTorch to perform the research.
And if the latest research is published with PyTorch, the industry starts to follow.
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 .
4. PyTorch comes with plenty of integrations to other machine learning libraries
PyTorch originated at Facebook due to a need to process the large amounts of data the company was getting.
They open-sourced it in 2017 to allow others to benefit from its capabilities.
But open-sourcing PyTorch also had the benefit of meaning 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 .
5. Bonus: PyTorch is fun
The most important reason.
With a couple of lines of PyTorch code, you and I can do things that weren’t possible with a team of 20 engineers and a year of compute time ten years ago.
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.
We’ll write every line together.
If I get it wrong, you’ll get it wrong.
And if I get it right, you’ll get it right too.
Bonus bonus: PyTorch or TensorFlow?
Although this article is focused on PyTorch, I’m putting this here because the question comes up a lot.
The simple answer is what I said before: learning the language of machine learning is more important than the framework you choose.
If PyTorch is used by the companies above, TensorFlow is used by Google (and many others).
What you can do in PyTorch, you can do in TensorFlow and what you can do in TensorFlow, you can do in PyTorch.
Learning the language of machine learning by coding PyTorch or TensorFlow, means you can bridge between the two if you need.
Flip a coin and pick one.
But you don’t have to pick if you don’t want to.
Because Zero to Mastery offers both.
How do I get started?
PyTorch runs on almost any computing system you can image (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 Zero to Mastery PyTorch course).
On Google Colab, you can start running PyTorch code straight away.
Such as the PyTorch Fundamentals notebook on?learnpytorch.io ?(a free online book to learn PyTorch from the fundamentals to building a machine learning application).
Try clicking the "Open in Colab" button up the top and seeing what happens.
And for those who prefer video, the Learn PyTorch in a day (literally) video contains 25+ hours of learning PyTorch in a code-first way!
ITSM enthusiast
1 年Actualy, I am in a midle of your TensorFlow course(Btw great job Daniel??), so should I start to learn PyTorch now? I read that it can be easier to understand in some way but I found more benefits in TensorFlow.?
5x AWS certified, Machine Learning || Generative AI, Python, XR, software developer, and a "Visionary".
1 年Having keen understanding in both PyTorch and Tensorflow really helps in discovering ways to fit use-case. But I do agree most of the times PyTorch is faster. ??
Aspiring Data Scientist | Machine Learning Enthusiast | Software || Python and C++ Programmer
1 年Pytorch or Tensorflow? Should we learn both or any of them is sufficient?
Business Controls Metrics
1 年Your PyTorch class on YouTube really enlightened me! Plus, all the extra material you shared was very valuable.
AI/Data Scientist | AI Agent Architect | eDiscovery Expert
1 年Love the material Daniel. You got me hooked on PyTorch and now I turned to PyTorch Lightning!