当前位置:网站首页>【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]
边栏推荐
- Optical cat super account password and broadband account password acquisition
- Fundamentals of PHP deserialization
- C language fcntl function
- 1017 a divided by B (20 points)
- B2020 points candy
- 4-29——4.32
- [ue4] HISM large scale vegetation rendering solution
- cpu飙升排查方法
- 2021-10-16 initial programming
- Pytoch deep learning and target detection practice notes
猜你喜欢

The picture quality has been improved! LR enhancement details_ Lightroom turns on AI photo detail enhancement: picture clarity increases by 30%

High quality workplace human beings must use software to recommend, and you certainly don't know the last one

QT program font becomes larger on computers with different resolutions, overflowing controls

【注意力机制】【首篇ViT】DETR,End-to-End Object Detection with Transformers网络的主要组成是CNN和Transformer

【Transform】【实践】使用Pytorch的torch.nn.MultiheadAttention来实现self-attention

Introduction to opengl4.0 tutorial computing shaders

Talking about part of data storage in C language

Vs+qt multithreading implementation -- run and movetothread
![[ue4] HISM large scale vegetation rendering solution](/img/a2/2ff2462207e3c3e8364a092765040c.jpg)
[ue4] HISM large scale vegetation rendering solution

PS tips - draw green earth with a brush
随机推荐
How does vs+qt set the software version copyright, obtain the software version and display the version number?
复合类型(自定义类型)
PHP GD image upload bypass
Zero copy underlying analysis
4-29——4.32
Find books ()
[ue4] geometry drawing pipeline
[ue4] material and shader permutation
Byte practice surface longitude
C language dup2 function
Global and Chinese markets for transparent OLED displays 2022-2028: Research Report on technology, participants, trends, market size and share
Yolov5进阶之七目标追踪最新环境搭建(二)
Simulation of LS -al command in C language
牛客 BM83 字符串變形(大小寫轉換,字符串反轉,字符串替換)
Global and Chinese market of marketing automation 2022-2028: Research Report on technology, participants, trends, market size and share
B2020 points candy
C language fcntl function
【Transform】【NLP】首次提出Transformer,Google Brain团队2017年论文《Attention is all you need》
[opengl] geometry shader
Zzuli:1053 sine function