当前位置:网站首页>pytorch自定义dataloder的时候,返回参数
pytorch自定义dataloder的时候,返回参数
2022-07-22 09:21:00 【yijun009】
比如我想在返回矩阵同时,也返回地址。只需要将这两个信息用字典封装起来一起返回。
在train的时候用XXX[‘path’]和XXX[‘data’]调用即可。(for i,XXX in in enumerate(train_loader))
class Tche_loader(data.Dataset):
def __init__(self, lowlight_images_path):
self.train_list = sorted(glob.glob(lowlight_images_path + "*.jpg"))
self.data_list = self.train_list
print("Total training examples:", len(self.train_list))
def __getitem__(self, index):
data_lowlight_path = self.data_list[index]
data_lowlight = Image.open(data_lowlight_path)
data_lowlight = (np.asarray(data_lowlight)/255.0)
data_lowlight = torch.from_numpy(data_lowlight).float()
return {
'path':data_lowlight_path,'data':data_lowlight.permute(2,0,1)}
def __len__(self):
return len(self.data_list)
any questions 请私信我
边栏推荐
- Summary 20220210
- BigDecimal中除法divide()方法的详细解析,带你走进源码的world
- strncpy() 复制字符串(受长度限制)
- Summary 20215 (Kruskal and PRIM)
- 【QT源代码复用】模拟QCompleter的弹窗方式
- Data Lake simple record
- PTA exercise 8-8 judging palindrome string
- bjyx
- Leetcode 653. sum of two IV - input BST
- Leetcode 116. fill in the next right node pointer of each node
猜你喜欢
PCV、PIL、Pillow安装
Strncpy() copy string (limited by length)
MySQL的语句执行顺序
App mobile terminal test [6] application program (APK) package management and activity
06. Liskov Substitution Principle (LSP)
Leetcode 105. constructing binary trees from preorder and inorder traversal sequences
NRF24L01 wireless module setting transmit receive mode method
连接mysql8.0出现caching-sha2-password问题
App mobile End test [6] application (APK) package Management and Activity
bjyx
随机推荐
1.mysql null 和 in;2.127.0.0.2是啥?
Strncpy() copy string (limited by length)
BigDecimal中除法divide()方法的详细解析,带你走进源码的world
1.QTableWidget的closable,2.pro/build_pass、member,3.QString&&
IP地址、CIRD格式网址、主机名正则表达式
Data Lake simple record
Qt | boîtes de dialogue modales et non modales qdialog
VLFeat、pydot配置
PTA exercise 8-8 judging palindrome string
06. Liskov Substitution Principle (LSP)
1.moveToThread的一个完整实例,2.qt表达式求值
Bull column - blog summary
Parameter index out of range (1 > number of parameters, which is 0).
Summary 20220211
Qt | 模态对话框和非模态对话框 QDialog
Pat class B 1019 digital black hole (20 points) (possible causes of measurement point errors)
sql 语法中 join 的所有用法总结(简单例子)
Flink学习笔记(四)Flink运行时架构
JSON序列化对象时,如何返回有空值的带属性名称json字符串?
Leetcode 653. sum of two IV - input BST