-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataset.py
More file actions
31 lines (22 loc) · 787 Bytes
/
dataset.py
File metadata and controls
31 lines (22 loc) · 787 Bytes
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
# padataset.py :power allocatio dataset
import os
import scipy.io as sio
from torch.utils.data import Dataset,DataLoader
__all__ = ["PADataset"]
class PADataset(Dataset):
def __init__(self,root,mode,scenario):
super(PADataset, self).__init__()
assert os.path.isdir(root)
assert mode in {"train","vaild","test"}
assert scenario in {5, 10, 15, 20, 25}
dir_data = os.path.join(root, f"{mode}_{scenario}.mat")
data = sio.loadmat(dir_data)
self.K = scenario
self.csis = data['csi']
self.powers = data['power']
def __len__(self):
return len(self.csis)
def __getitem__(self,idx):
csi = self.csis[idx]
power = self.powers[idx]
return (csi,power)