当前位置:网站首页>pytorch框架学习(9)torchvision.transform
pytorch框架学习(9)torchvision.transform
2022-08-10 05:29:00 【Time.Xu】
前言
之前我们在《pytorch框架学习(6)细节篇》里有提过torchvision.transforms.Compose可以用于对数据进行预处理。本片文章我们将系统的对transform进行学习。
** Transforms的结构**
我们打开transforms.py的源文件可以看到,文件中定义了非常多的class
** Transforms的作用**
transforms就相当于一个图像处理的工具箱,不同的class就是不同的工具。
** Transforms的用法**
transforms.Compose
将几个变换组合在一起。这个转换不支持torchscript
Converts a PIL Image or numpy.ndarray (H x W x C) in the range [0, 255] to a torch.FloatTensor of shape (C x H x W) in the range [0.0, 1.0]
Example:
>>> transforms.Compose([
>>> transforms.CenterCrop(10),
>>> transforms.ToTensor(),
>>> ])
注意:transforms.Compose的参数应该是一个list(列表)
transforms.ToTensor
转换一个’PIL.Image’或’numpy.ndarray’张量。这个转换不支持torchscript。
transforms.Normalize
用均值和标准差归一化tensor image。
transforms.Resize
调整输入图像的大小到给定的大小。
the image can be a PIL Image or a torch Tensor, in which case it is expected to have […, H, W] shape, where … means an arbitrary number of leading dimensions
- 这个地方要说一下,Resize使用的是双线性插值,如果是做分类问题,有可能出现分割标签出现问题的情况
总结来说,我们在调用这些包的时候,我们需要重点注意输入输出的type。
边栏推荐
- 【静态代理】
- WSTP初体验
- Touch chip used in smart touch remote control
- Conda creates a virtual environment method and pqi uses a domestic mirror source to install a third-party library method tutorial
- flex related
- What are the common commands of mysql
- 手把手带你写嵌入式物联网的第一个项目
- Shield Alt hotkey in vscode
- Guys, is it normal that the oracle archive log grows by 3G in 20 minutes after running cdc?
- 线性代数(四)
猜你喜欢
随机推荐
Kubernetes:(十六)Ingress的概念和原理
SQLSERVER 2008 parses data in Json format
Touch chip used in smart touch remote control
在vscode中屏蔽Alt热键
Kubernetes:(十七)Helm概述、安装及配置
Interface documentation evolution illustration, some ancient interface documentation tools, you may not have used it
Pulsar中游标的工作原理
论文精读 —— 2021 CVPR《Progressive Temporal Feature Alignment Network for Video Inpainting》
FPGA工程师面试试题集锦31~40
How cursors work in Pulsar
CORS跨域资源共享漏洞的原理与挖掘方法
You can‘t specify target table ‘kms_report_reportinfo‘ for update in FROM clause
What are the common commands of mysql
Nexus_Warehouse Type
How does Jenkins play with interface automation testing?
The time for flinkcdc to read pgsql is enlarged. Does anyone know what happened? gmt_create':1
oracle rac 11g安装执行root.sh时报错
Qiskit 学习笔记2
ThreadPoolExecutor线程池原理
pytorch 学习