-
Notifications
You must be signed in to change notification settings - Fork 4
/
dataset.py
32 lines (24 loc) · 968 Bytes
/
dataset.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
import torch
from torch.utils.data import Dataset
import numpy as np
class DecnnDataset(Dataset):
def __init__(self, path=None):
data = np.load(path)
self._sentences = torch.from_numpy(data['sentences']).long()
self._labels = torch.from_numpy(data['labels']).long()
self._len = self._sentences.size(0)
def __getitem__(self, index):
return self._sentences[index], self._labels[index]
def __len__(self):
return self._len
class GcaeDataset(Dataset):
def __init__(self, path):
data = np.load(path)
self._sentences = torch.from_numpy(data['sentences']).long()
self._terms = torch.from_numpy(data['terms']).long()
self._labels = torch.from_numpy(data['labels']).long()
self._len = self._labels.size(0)
def __getitem__(self, index):
return self._sentences[index], self._terms[index], self._labels[index]
def __len__(self):
return self._len