🏆 Take the free Top-Rated Session from TechXchange in Las Vegas and Build Your First GenAI Application the Right Way! Learn more

Offered By: IBMDeveloper

Getting Started with Machine Learning with PyTorch

PyTorch is a leading open source framework for AI research and commercial production in machine learning. It is used to build, train, and optimize deep learning neural networks for applications such as image recognition, natural language processing, and speech recognition.

Continue reading

Guided Project

Artificial Intelligence

1.89k+ Enrolled
4.5
(339 Reviews)

At a Glance

PyTorch is a leading open source framework for AI research and commercial production in machine learning. It is used to build, train, and optimize deep learning neural networks for applications such as image recognition, natural language processing, and speech recognition.

What is PyTorch?

PyTorch is a leading open source framework for AI research and commercial production in machine learning. It is used to build, train, and optimize deep learning neural networks for applications such as image recognition, natural language processing, and speech recognition. It provides computation support for CPU, GPU, parallel, and distributed training on multiple GPUs on multiple nodes. PyTorch is Pythonic, making it easy for data scientists and developers to build and debug complex machine learning workflows. PyTorch is also flexible and easily extensible, with specific libraries and tools available for many different domains.

The PyTorch community is extensive and committed to growing the project and to delivering state-of-the-art features as the world of AI continues to expand, making it a leading framework for AI models of all sizes.

Model Training with PyTorch

PyTorch provides the building blocks for defining models. An AI model, or neural network, is defined in PyTorch using the subclasses of Module in the torch.nn namespace. They can be arranged in multiple layers using a nested structure which allows for easily building complex architectures. When training the model, the backward pass, or back propagation, adjusts the model weights using PyTorch's built-in differentiation engine called autograd. Autograd handles the implementation of the backward pass of the model, so that model developers don't need to worry about implementing it from scratch.

Once the model is implemented, PyTorch provides the DataLoader and Dataset classes to enable using pre-loaded datasets or your own data to train the model. Dataset provides access to the data and corresponding labels and DataLoader can be used to provide iterable access to the dataset for use in training and validation loops.

With a model implemented and training and validation data available, the model can be trained to optimize the parameters, or weights, of the model. Multiple passes, or epochs, are made over the dataset to train and validate the model parameters. After completing a training loop, a validation loop is typically run to check if the model's predictive performance is improving. In PyTorch, model parameters are kept in an internal state dictionary called state_dict. The save method can be used to save the model parameters. 
At IBM, we use PyTorch to train foundation models that power the generative AI capabilities of the IBM watsonx platform.

A Look at the Project Ahead

After completing this lab you will be able to:
  • Install necessary PyTorch libraries.
  • Use PyTorch to build, train and evaluate neural networks.
  • Save the trained model parameters and use them later for inferencing.

What You'll Need

You just need a web browser!  Regarding prior skills,  you will need basic Python programming knowledge.

Everything else is provided to you via the IBM Skills Network Labs environment, where you will have access to the Cloud IDE and Python runtimes that we offer as part of the IBM Skills Network Labs environment. 

This platform works best with current versions of Chrome, Edge, Firefox, Internet Explorer or Safari.

Estimated Effort

1 Hour

Level

Beginner

Skills You Will Learn

Machine Learning, Open Source AI, Python, PyTorch

Language

English

Course Code

GPXX0W98EN

Tell Your Friends!

Saved this page to your clipboard!

Have questions or need support? Chat with me 😊