当前位置:网站首页>【Pytorch】学习笔记(一)创建自己的数据集
【Pytorch】学习笔记(一)创建自己的数据集
2022-07-21 02:31:00 【高小耸】
自定义数据集
要想使用自己的数据集,必须实现3个方法: __init__()
,__len__()
与__getitem__()
.___init__()
:
在初始化数据集时调用一次,我们在初始化方法里完成一些数据的初始化工作,例如,初始化图片路径,标注文件以及数据预处理的初始化。__len__()
:
返回数据集中的数据数量__getitem__()
:__getitem__()
的方法根据给定的idx,加载然后返回一个样本。基于idx,找到图片并转换成tensor.遍历label,调用自定义的transform函数来完成图片的预处理。最终返回tensor化的图片和对应的标签元组。
边栏推荐
- STM32 OLED显示屏移植工程方法
- Exchange class sorting
- Design of the multi live architecture in different places of the king glory mall
- QT4、5、6各版本之间的特点和选择
- 0715 today's song list one last kiss, exhausted
- Visual solution of digital twin landing high-speed railway bridge
- Cookie、Session、Token三者的区别
- Okaleido tiger NFT is about to log in to binance NFT platform, and the era of NFT rights and interests is about to start
- Next generation wireless LAN -- PHY interoperability between 802.11n and traditional 11ag OFDM devices
- ES 自定义分析器
猜你喜欢
powermock实战
DP --- knapsack problem
交换类排序
[mathematical modeling] juvenile delinquency | stepwise regression analysis | residual analysis rcoplot
LabVIEW中通过编程获取前面板的屏幕截图
ES 自定义分析器
全新红包封面平台可搭建分站独立后台的源码
[04] through the power consumption wall, what aspects should we improve "performance"?
This is the package I am most familiar with JSON?
视频融合云平台EasyCVR重启服务器后,级联离线如何解决?
随机推荐
视频融合云平台EasyCVR重启服务器后,级联离线如何解决?
Skiasharp's WPF self drawn bouncing ball (case version)
[04] through the power consumption wall, what aspects should we improve "performance"?
STM32 OLED显示屏移植工程方法
Midas Capital向Moonbeam带来Fuse Pools
第一部分—C语言基础篇_8. 内存管理
[translation] technical writing of developers
深度优先与广度优先的思想
银行不是唐僧肉 银行是金融安全的坚实屏障。
C language type conversion
Hongmeng harmonios deveco studio reported an error unistall_ FAILED_ INTERNAL_ ERROR
Resttemplate calls post\get
Oracle startup command
众昂矿业:萤石行业发展四大趋势
C language practice topic + answer: 26-30
Golang collection: custom types and method sets
API Test
Security video monitoring platform easycvr database fields cannot be updated, how to optimize?
C语言常量与变量
Excel to JSON (tree structure)