-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_pre.py
28 lines (25 loc) · 814 Bytes
/
data_pre.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
############Data Preparation############
import scipy.io
import numpy as np
import torch
class DATASET(object):
def read_data(self):
site1 = scipy.io.loadmat('/media/qqw/Elements/qqw/A_PycharmProjects/mywork_demo/abide.mat')
A = np.squeeze(site1['A'].T)
series = []
for i in range(len(A)):
signal = A[i]
series.append(signal)
X = np.array(series)
y = np.squeeze(site1['label'])
return X, y
def __init__(self):
super(DATASET, self).__init__()
X, y = self.read_data()
self.X = torch.from_numpy(X)
self.y = torch.from_numpy(y)
self.n_samples = X.shape[0]
def __len__(self):
return self.n_samples
def __getitem__(self, index):
return self.X[index], self.y[index]