当前位置:网站首页>transform的结构及用法
transform的结构及用法
2022-06-23 07:33:00 【booze-J】
一、transform作用
结构图1

结构图2

二、实际应用tensor类型
详细代码如下:
from torch.utils.tensorboard import SummaryWriter
from torchvision import transforms
from PIL import Image
# python 的用法 -》 tensor数据类型
# 通过transform.ToTensor去看两个问题
# 2、为什么我们需要Tensor数据类型 :因为tensor类型数据包含了训练神经网络所需要的属性
image_path = r"D:\pycharm_professional\PycharmProjects\learning_pytorch\dataset\train\ants_image\0013035.jpg"
img = Image.open(image_path)
writer = SummaryWriter("logs") # ctrl+P查看参数 ctrl + alt解决爆红问题
# 1、transforms该如何使用(python)
# 生成一个对象
tensor_trans = transforms.ToTensor()
tensor_img = tensor_trans(img)
# 使用tensorboard展示
writer.add_image("tensor_img",tensor_img,1)
writer.close()
terminal终端输入指令tensorboard --logdir="logs" --port=6007
结果如下:
边栏推荐
- 1. probability theory - combination analysis
- 带你玩tiktok就这么简单
- 测试apk-异常管控NetTraffic攻击者开发
- 1.概率论-组合分析
- three. Solution to stripe shadow and grid shadow in JS
- [veusz] import 2D data in CSV
- 2022 final examination of software project management of School of software, Shandong University (recall version)
- 建立一有序的顺序表,并实现下列操作: 1.把元素x插入表中并保持有序; 2.查找值为x的元素,若找到将其删除; 3.输出表中各元素的值。
- 论文伪代码规范,伪代码在线编辑器,
- HCIP之路第八次实验
猜你喜欢

Design of temperature detection and alarm system based on 51 single chip microcomputer

EXCEL VBA 入门与实用例子

测试apk-异常管控NetTraffic攻击者开发

30 sets of report templates necessary for the workplace, meeting 95% of the report needs, and no code is required for one click application

Talk about routing design in service governance

Matlab random volatility SV, GARCH using MCMC Markov chain Monte Carlo method to analyze exchange rate time series

Interview questions of a company in a certain month of a certain year (1)

The eighth experiment of hcip Road

socket编程(多进程)

忽略超长参数违规
随机推荐
利用for循环输出一个字母三角形
11 字符串函数
Vs problems when connecting to SQL myconn OPen(); cannot execute
AVL树的实现
2.概率论-概率论公理
PHP 文件包含 -ctf
1.概率论-组合分析
EXCEL VBA 入门与实用例子
快速删除代码里面的node_modules
2. probability theory - axiom of probability theory
socket编程(多进程)
Quickly delete the node in the code_ modules
domain controller
【markdown】markdown 教程大归纳
数学知识:欧拉函数—欧拉函数
unity转微信小程序小游戏
Socket programming (multithreading)
openni. utils. OpenNIError: (OniStatus.ONI_STATUS_ERROR, b‘DeviceOpen using default: no devices found‘
1278_ FreeRTOS_ Understand the delayed task with the prvaddcurrenttasktodelayedlist interface
firewalld 配置文件的位置