MCPcopy Create free account
hub / github.com/activeloopai/deeplake / TorchDataset

Class TorchDataset

python/deeplake/_torch.py:11–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11class TorchDataset(Dataset):
12
13 def __init__(self, ds: deeplake.Dataset, transform=None):
14 self.ds = ds
15 self.transform = transform
16 self.column_names = [col.name for col in ds.schema.columns]
17
18 def __len__(self):
19 return len(self.ds)
20
21 def __getitem__(self, idx):
22 sample = self.ds[idx]
23 if self.transform:
24 return self.transform(sample)
25 else:
26 out = {}
27 for col in self.column_names:
28 out[col] = sample[col]
29 return out

Callers 1

_pytorchFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected