python - What is the best clean way to handle three datasets with different size for a training neural net?
问题描述
I have three datasets,each has different lengths. I have a model with three input pipeline (similar to Siamese, but three input pipeline) and therefore, I have to separately feed the data. I cannot concatenate them. The first one has around 600 ,second one has 3000 and last one has 40000 samples. In each training loop, I want to go through them and feed them into my model.
I defined three datasets and three dataloaders in pytorch; however, I am not sure how to iterate over them?
In the case of two, I have tried cycle over the smaller dataset and worked. But it is not working for three.
for step, ((images_Di, labels_Di),(images_Dj, labels_Dj)) in enumerate(zip(loader_D2, cycle(loader_D1))):
I appreciate if any one help me how is best way to handle them.
解决方案
为什么要拥有 3 个不同的数据集/加载器?如果每个数据集中元素的大小相同,那么您只需将所有数据集中的图像和标签连接起来,然后创建一个 pytorch 数据集和加载器。那不是更简单吗?
推荐阅读
- oracle-sqldeveloper - 获取 ORACLE SQL 开发人员中单个员工的总出勤率
- python - 查找最接近的元素值(最小值和最大值)以及差异百分比
- gradle - 在从包含三个 .gradle 文件的存储库创建自定义 gradle 插件时需要帮助
- javascript - Owl Carousel 2:添加标题,单击并相应地移动到项目
- hive - Apache Ranger 中基于标签的策略不起作用
- python - ImportError:无法从“tensorflow.python.profiler”导入名称“trace”
- c# - KeyPerFileConfigurationSource 没有同时设置目录路径和忽略条件的选项
- node.js - 如何更新 AWS Lambda index.js 文件
- javascript - Formdata 不会将数字输入字段转换为字符串
- leaflet - 在 QGIS 中,qgis2web 插件是否支持点图层的热图符号系统?