-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataloader.h
42 lines (36 loc) · 1.2 KB
/
dataloader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// Created by Dengweiwei on 2021/11/15.
//
#ifndef EXPERIMENT_DATALOADER_H
#define EXPERIMENT_DATALOADER_H
#include "datasets.h"
namespace dww{
enum DATA_CAT{
TRIN = 0, //训练数据
TEST, //测试数据
VAL //valuation数据
};
struct BaseDataLoader{
BaseDataLoader() = delete;
explicit BaseDataLoader(int64_t batch) : batch_size(batch),samples_num(0){
}
virtual int64_t get_batch_num() = 0;
// 所有 batch 的 image 样本
std::vector<torch::Tensor> images;
// 所有 batch 的 label 样本
std::vector<torch::Tensor> labels;
int64_t batch_size;
int64_t samples_num;
};
struct MedDataSetLoader : BaseDataLoader{
MedDataSetLoader() = delete;
explicit MedDataSetLoader(const MedDataSet& data,DATA_CAT cat=TRIN,int64_t batch_sz = 32);
int64_t get_batch_num() override;
};
struct MNISTDataSetLoader : BaseDataLoader{
MNISTDataSetLoader() = delete;
explicit MNISTDataSetLoader(const MNISTDataSet& data,DATA_CAT cat=TRIN,int64_t batch_sz = 32);
int64_t get_batch_num() override;
};
}
#endif //EXPERIMENT_DATALOADER_H