-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathData.py
More file actions
41 lines (34 loc) · 1.12 KB
/
Data.py
File metadata and controls
41 lines (34 loc) · 1.12 KB
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
import torch
from torch import nn
from torch.autograd import Variable
from DataSet import DataSet
from Sampler import Sampler
import pdb
class Data:
''' specifies the
- file
- dataparser for the file (dataset)
- sampler
'''
def __init__(self, data_params):
super(Data, self).__init__()
self.data_file = data_params["file"]
self.n_dataset = data_params["dataset"]
self.dataset = DataSet.get(self.data_file, self.n_dataset, data_params[self.n_dataset])
self.n_sampler = data_params["sampler"]
self.sampler = Sampler.get(self.dataset, self.n_sampler, data_params[self.n_sampler])
self.num_points = 0
self.total_num_points = self.sampler.total_size
def next(self):
num, X = self.sampler.next()
self.num_points += num
return X
def end(self):
return self.num_points >= self.total_num_points
def reset(self):
self.num_points = 0
self.sampler.reset()
def len(self):
return self.total_num_points
def batch_size(self):
return self.sampler.batch_size