Computer Vision
73 words
1 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Computer Vision [Join Discord](https://discord.gg/gE2m4Qrdqv) [Previous**Deep Learning (PyTorch)**](/notes/04-degree-electives-bsda4001-ds-ai-lab-week03-03-deep-learning-pytorch)[Next**NLP with Hugging Face**](/notes/04-degree-electives-bsda4001-ds-ai-lab-week05-05-nlp-huggingface)

Computer Vision
pythonimport torch import torch.nn as nn import torchvision import torchvision.transforms as transforms # Load CIFAR-10 transform = transforms.Compose([ transforms.ToTensor(), transforms.Normalize((0.5,), (0.5,)) ]) trainset = torchvision.datasets.CIFAR10( root='./data', train=True, download=True, transform=transform ) trainloader = torch.utils.data.DataLoader( trainset, batch_size=32, shuffle=True ) # Pre-trained ResNet model = torchvision.models.resnet18(pretrained=True) # Freeze layers for param in model.parameters(): param.requires_grad = False # Replace classifier model.fc = nn.Linear(512, 10)