当前位置:网站首页>【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]
边栏推荐
- Web server code parsing - thread pool
- Vs+qt application development, set software icon icon
- [ue4] material and shader permutation
- Rasterization: a practical implementation (2)
- Zzuli:1054 monkeys eat peaches
- [graphics] efficient target deformation animation based on OpenGL es 3.0
- 4-24--4-28
- Global and Chinese market of optical fiber connectors 2022-2028: Research Report on technology, participants, trends, market size and share
- 7-3 rental (20 points)
- Byte practice surface longitude
猜你喜欢
How to color ordinary landscape photos, PS tutorial
5-1 blocking / non blocking, synchronous / asynchronous
Tencent internship interview sorting
Série yolov5 (i) - - netron, un outil de visualisation de réseau
cpu飙升排查方法
Bucket sorting in C language
Rasterization: a practical implementation (2)
Pytoch deep learning and target detection practice notes
远程服务器后台挂起 nohup
[graphics] real shading in Unreal Engine 4
随机推荐
Zzuli: cumulative sum of 1050 factorials
[graphics] efficient target deformation animation based on OpenGL es 3.0
Zhejiang University Edition "C language programming (4th Edition)" topic set reference ideas set
Vs+qt multithreading implementation -- run and movetothread
Talking about part of data storage in C language
Zzuli:1043 max
[opengl] advanced chapter of texture - principle of flowmap
dllexport和dllimport
NOI OPENJUDGE 1.5(23)
[graphics] hair simulation in tressfx
. Net six design principles personal vernacular understanding, please correct if there is any error
什么是embedding(把物体编码为一个低维稠密向量),pytorch中nn.Embedding原理及使用
CentOS7部署哨兵Redis(带架构图,清晰易懂)
The latest M1 dedicated Au update Adobe audit CC 2021 Chinese direct installation version has solved the problems of M1 installation without flash back!
[graphics] adaptive shadow map
Global and Chinese market of iron free motors 2022-2028: Research Report on technology, participants, trends, market size and share
Address book sorting
[engine development] in depth GPU and rendering optimization (basic)
NOI OPENJUDGE 1.6(09)
[opengl] geometry shader