This is the multi-page printable view of this section.
Click here to print.
Return to the regular view of this page.
Pytorch
- Pytorch basics tutorials:
Learn the Basics — PyTorch Tutorials 2.6.0+cu124 documentation
pytorch.org
Most machine learning workflows involve working with data, creating models, optimizing model parameters, and saving the trained models.
- Training an image classifier using CNN
Deep Learning with PyTorch: A 60 Minute Blitz — PyTorch Tutorials 2.6.0+cu124 documentation
pytorch.org
1 - Quick Start
runs through the API for common tasks in machine learning
PyTorch is an open-source deep learning framework that’s known for its flexibility and ease-of-use.
Python Grammer
understand that as a playground with instructure.
define a function use def , function in python can return multiable values
no need of type attribute
In python list is reinitializable, and turple is fixed and unchangable
import math
def move(x, y, step, angle=0):
nx = x + step * math.cos(angle)
ny = y - step * math.sin(angle)
return nx, ny
>>> x, y = move(100, 100, 60, math.pi / 6)
>>> print(x, y)
151.96152422706632 70.0
A huge improve is Python supports default para. In tons of value need to write value, we can ignore the fixed values and only trans uniqe ones.
WARN:
python 的默认参数是在方法外部传入的, 一定注意Python是引用传参, 默认参数必须指向不变对象!
Written in Python, it’s relatively easy for most machine learning developers to learn and use.
For data, we have two primitives in toch
torch.utils.data.DataLoader
torch.utils.data.Dataset
Dataset include a bunch of samples and corresponding lables.
Note here In python map called dict
DataLoad add Itrable ability
we mainly use TorchVision package of FashionMNIST dataset dataset.pytorch offer domain-specific libraryies.
In this Dataset
includes two arguments: transform
and target_transform
to modify the samples and labels respectively.
DataSet & DataLoaders
Tensors
Pytorch use an unique data type called Tensors, similar to a multidimensional array, used to store and caculate input and output of a model.
a important feature is
tensors can run on GPUs to accelerate computing.
Graphs