-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefectdataset.py
55 lines (43 loc) · 980 Bytes
/
defectdataset.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
from torch.utils.data import Dataset
class DefectDataset(Dataset):
def __init__(self, X, y):
"""
Store inputs and outputs
Parameters
----------
X : Numpy array
Features.
y : Numpy array
targets.
Returns
-------
None.
"""
# store the inputs and outputs
self.X = X.astype('float32')
self.y = y
self.y = self.y.reshape((len(self.y), 1))
def __len__(self):
"""
Number of rows in the dataset
Returns
-------
int
Length of dataset.
"""
return len(self.X)
def __getitem__(self, idx):
"""
Get a row at an index
Parameters
----------
idx : int
Index to get.
Returns
-------
list
features.
int
target.
"""
return self.X[idx], self.y[idx]