当前位置:网站首页>[pytorch learning notes] transforms
[pytorch learning notes] transforms
2022-07-03 15:00:00 【liiiiiiiiiiiiike】
Transforms
all torchvision Data sets have two parameters transform and target_transform, The former enhances the image , The latter deals with labels ( Label smoothing ).Fashionmnist yes PIL Image format , The label is an integer . For training , It is necessary to convert the features into normalized tensor, And label one-hot Coding is convenient softmax. have access to ToTensor and 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() take PIL Image or ndarray Convert to FloatTensor, And normalize the pixels to [0,1]
边栏推荐
- Global and Chinese market of postal automation systems 2022-2028: Research Report on technology, participants, trends, market size and share
- Yolov5进阶之七目标追踪最新环境搭建(二)
- Global and Chinese market of lighting control components 2022-2028: Research Report on technology, participants, trends, market size and share
- 什么是one-hot encoding?Pytorch中,将label变成one hot编码的两种方式
- [opengl] pre bake using computational shaders
- 创业团队如何落地敏捷测试,提升质量效能?丨声网开发者创业讲堂 Vol.03
- QT program font becomes larger on computers with different resolutions, overflowing controls
- [engine development] rendering architecture and advanced graphics programming
- Centos7 deployment sentry redis (with architecture diagram, clear and easy to understand)
- Global and Chinese market of air cargo logistics 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢
随机推荐
TPS61170QDRVRQ1
Global and Chinese market of solder bars 2022-2028: Research Report on technology, participants, trends, market size and share
TPS61170QDRVRQ1
Troubleshooting method of CPU surge
[graphics] real shading in Unreal Engine 4
[graphics] efficient target deformation animation based on OpenGL es 3.0
Incluxdb2 buckets create database
The latest M1 dedicated Au update Adobe audit CC 2021 Chinese direct installation version has solved the problems of M1 installation without flash back!
Leetcode the smallest number of the rotation array of the offer of the sword (11)
How does vs+qt set the software version copyright, obtain the software version and display the version number?
Global and Chinese market of Bus HVAC systems 2022-2028: Research Report on technology, participants, trends, market size and share
C # realizes the login interface, and the password asterisk is displayed (hide the input password)
Vs+qt multithreading implementation -- run and movetothread
Zzuli:1047 logarithmic table
Zzuli:1058 solving inequalities
Centos7 deployment sentry redis (with architecture diagram, clear and easy to understand)
Zzuli:1056 lucky numbers
PS tips - draw green earth with a brush
ASTC texture compression (adaptive scalable texture compression)
Byte practice plane longitude 2








