Tara, aral tayo! (Come on, let's learn together!)

Learn

A learning path from your first tensor to deployment, sample code that runs, and the official materials and projects to go further.

Learning path

Three stages, from your first tensor to deployment. Our learning programs follow the same stages, and each stage links to free tutorials and documentation you can study on your own.

  1. PyTorch Fundamentals

    Tensors, autograd, datasets and data loaders, and building, training, and saving your first neural networks.

  2. PyTorch Techniques and Ecosystem Tools

    Transfer learning and computer vision with TorchVision, text models with Hugging Face, hyperparameter tuning, and faster training.

  3. PyTorch Advanced Architectures and Deployment

    Custom architectures, compiling and exporting models, distributed training, and running models on servers and edge devices.

Prefer a structured course? The PyTorch for Deep Learning Professional Certificate by DeepLearning.AI has three courses with the same names as these stages. It is a third-party course and is not run by PyTorch Philippines.

Sample code

Three short programs that run on the latest PyTorch. Install PyTorch, then paste them into Python or a notebook.

Tensors

Create tensors, do math, and move work to a GPU or other accelerator when one is available.

import torch

x = torch.tensor([[1.0, 2.0], [3.0, 4.0]])
y = torch.ones(2, 2)

print(x + y)          # element-wise addition
print(x @ y)          # matrix multiplication
print(x.mean(), x.shape)

# Use a GPU or other accelerator (CUDA, Apple MPS, ...) when one is available.
device = torch.accelerator.current_accelerator() if torch.accelerator.is_available() else "cpu"
x = x.to(device)
print(x.device)

Autograd

PyTorch records operations on tensors and computes gradients for you with backward().

import torch

w = torch.tensor(2.0, requires_grad=True)
x = torch.tensor(3.0)

loss = (w * x - 1.0) ** 2   # a tiny squared-error loss
loss.backward()             # compute d(loss)/dw automatically

print(loss.item())          # 25.0
print(w.grad)               # tensor(30.)

Train a model

Fit a linear model to noisy data with a standard training loop: forward pass, loss, backward pass, optimizer step.

import torch
from torch import nn

# Learn y = 3x + 2 from noisy samples.
torch.manual_seed(0)
x = torch.rand(256, 1)
y = 3 * x + 2 + 0.05 * torch.randn(256, 1)

model = nn.Linear(1, 1)
optimizer = torch.optim.SGD(model.parameters(), lr=0.5)
loss_fn = nn.MSELoss()

for epoch in range(200):
    optimizer.zero_grad()
    loss = loss_fn(model(x), y)
    loss.backward()
    optimizer.step()

print(f"weight={model.weight.item():.2f} bias={model.bias.item():.2f} loss={loss.item():.4f}")

Official materials

Learn the Basics

The official step-by-step introduction to tensors, datasets, models, training, and saving.

PyTorch Tutorials

Official tutorials for vision, text, audio, reinforcement learning, and deployment.

PyTorch Recipes

Short, focused examples for specific tasks such as saving models or profiling code.

PyTorch Forums

Ask questions and learn from the global PyTorch community.

Open-source projects

Widely used projects in the PyTorch ecosystem. Read their code, try their examples, and contribute.

torchvision

Datasets, pretrained models, and image transforms for computer vision.

PyTorch Lightning

Organizes PyTorch code to train models at scale with less boilerplate.

timm

A large collection of image models, layers, and training utilities.

Captum

Model interpretability and understanding for PyTorch.

ExecuTorch

Run PyTorch models on mobile, embedded, and edge devices.

Install PyTorch

Select your preferences and run the install command. Stable represents the most currently tested and supported version of PyTorch. This should be suitable for many users. Preview is available if you want the latest, not fully tested and supported, builds that are generated nightly. Please ensure that you have met the prerequisites below (e.g., numpy), depending on your package manager. You can also install previous versions of PyTorch. Note that LibTorch is only available for C++.

NOTE: Latest PyTorch requires Python 3.11 or later.

PyTorch Build
Your OS
Package
Language
Compute Platform
Run this Command:
PyTorch Build
Stable (1.13.0)
Preview (Nightly)
Your OS
Linux
Mac
Windows
Package
Pip
LibTorch
Source
Language
Python
C++ / Java
Compute Platform
CUDA 11.8
CUDA 12.1
CUDA 12.4
ROCm 5.2
CPU
Run this Command:
pip install torch torchvision

Previous versions of PyTorch

Quick Start With
Cloud Partners

Get up and running with PyTorch quickly through popular cloud platforms and machine learning services.

PyTorchPH on GitHub

The source of this website and our community files. Contributions are welcome.

Go to GitHub

Campus Labs

University chapters across Luzon, the Visayas, and Mindanao.

Meet the Campus Labs

Community page

Announcements, event posters, and updates from PyTorch Philippines.

Go to Facebook