Function
data_loader
(
nchannel=3,
max_label=5,
is_classification=True,
seed=-1,
batch_size=2,
dtype=torch.float32,
)
Source from the content-addressed store, hash-verified
| 55 | |
| 56 | |
| 57 | def data_loader( |
| 58 | nchannel=3, |
| 59 | max_label=5, |
| 60 | is_classification=True, |
| 61 | seed=-1, |
| 62 | batch_size=2, |
| 63 | dtype=torch.float32, |
| 64 | ): |
| 65 | if seed >= 0: |
| 66 | torch.manual_seed(seed) |
| 67 | |
| 68 | data = [" X ", " X X ", " XXXXX "] |
| 69 | |
| 70 | # Generate coordinates |
| 71 | coords = [get_coords(data) for i in range(batch_size)] |
| 72 | coords = ME.utils.batched_coordinates(coords) |
| 73 | |
| 74 | # features and labels |
| 75 | N = len(coords) |
| 76 | feats = torch.arange(N * nchannel).view(N, nchannel).to(dtype) |
| 77 | label = (torch.rand(batch_size if is_classification else N) * max_label).long() |
| 78 | return coords, feats, label |