当前位置:网站首页>【pytorch学习笔记】Transforms
【pytorch学习笔记】Transforms
2022-07-03 14:53:00 【liiiiiiiiiiiiike】
Transforms
所有torchvision数据集都有两个参数transform和target_transform,前者对图像增强,后者是对标签处理(标签平滑)。Fashionmnist是PIL图像格式,标签是整数。对于训练,需要将特征转换成归一化后的tensor,并将标签进行one-hot编码方便softmax。可以使用ToTensor和Lambda。
import torch
from torchvision import datasets
from torchvision.transforms import ToTensor, Lambda
ds = datasets.FashionMNIST(
root="data",
train=True,
download=True,
transform=ToTensor(),
target_transform=Lambda(lambda y: torch.zeros(10, dtype=torch.float).scatter_(0, torch.tensor(y), value=1))
)
ToTensor()
ToTensor()将PIL图像或者ndarray转换为FloatTensor,并将像素点归一化到[0,1]
边栏推荐
- Pytorch深度学习和目标检测实战笔记
- 4-20-4-23 concurrent server, TCP state transition;
- Zzuli:1044 failure rate
- Zhejiang University Edition "C language programming (4th Edition)" topic set reference ideas set
- Chapter 14 class part 1
- Zzuli:1047 logarithmic table
- Solve the problem that PR cannot be installed on win10 system. Pr2021 version -premiere Pro 2021 official Chinese version installation tutorial
- 【Transform】【NLP】首次提出Transformer,Google Brain团队2017年论文《Attention is all you need》
- Open under vs2019 UI file QT designer flash back problem
- Global and Chinese markets of AC electromechanical relays 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
随机推荐
Zzuli: sum of 1051 square roots
How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
Dllexport and dllimport
Global and Chinese markets for sterile packaging 2022-2028: Research Report on technology, participants, trends, market size and share
Address book sorting
Vs+qt multithreading implementation -- run and movetothread
Global and Chinese markets for flexible chips 2022-2028: Research Report on technology, participants, trends, market size and share
The latest M1 dedicated Au update Adobe audit CC 2021 Chinese direct installation version has solved the problems of M1 installation without flash back!
Yolov5 advanced nine target tracking example 1
dllexport和dllimport
4-20-4-23 concurrent server, TCP state transition;
B2020 points candy
Yolov5系列(一)——网络可视化工具netron
Devaxpress: range selection control rangecontrol uses
Zzuli:1044 failure rate
PS tips - draw green earth with a brush
[combinatorics] permutation and combination (set combination, one-to-one correspondence model analysis example)
[graphics] hair simulation in tressfx
Introduction to opengl4.0 tutorial computing shaders
QT - draw something else