MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / TensorDataset

Class TensorDataset

lib/utils/data/dataset.py:26–46  ·  view source on GitHub ↗

Dataset wrapping data and target tensors. Each sample will be retrieved by indexing both tensors along the first dimension. Arguments: data_tensor (Tensor): contains sample data. target_tensor (Tensor): contains sample targets (labels).

Source from the content-addressed store, hash-verified

24
25
26class TensorDataset(Dataset):
27 """Dataset wrapping data and target tensors.
28
29 Each sample will be retrieved by indexing both tensors along the first
30 dimension.
31
32 Arguments:
33 data_tensor (Tensor): contains sample data.
34 target_tensor (Tensor): contains sample targets (labels).
35 """
36
37 def __init__(self, data_tensor, target_tensor):
38 assert data_tensor.size(0) == target_tensor.size(0)
39 self.data_tensor = data_tensor
40 self.target_tensor = target_tensor
41
42 def __getitem__(self, index):
43 return self.data_tensor[index], self.target_tensor[index]
44
45 def __len__(self):
46 return self.data_tensor.size(0)
47
48
49class ConcatDataset(Dataset):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected