MCPcopy Create free account
hub / github.com/MotrixLab/insactor / numpy_collate

Function numpy_collate

diffmimic/utils/data.py:11–18  ·  view source on GitHub ↗
(batch)

Source from the content-addressed store, hash-verified

9
10
11def numpy_collate(batch):
12 if isinstance(batch[0], np.ndarray):
13 return np.stack(batch)
14 elif isinstance(batch[0], (tuple,list)):
15 transposed = zip(*batch)
16 return [numpy_collate(samples) for samples in transposed]
17 else:
18 return np.array(batch)
19
20
21class NumpyLoader(data.DataLoader):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected