Torch dataloader utils
collate_neighbor_sparse_matrix_batch(batch)
Collates a batch of samples with neighbor data into a single batch.
This collation function handles the output format when SingleCellMemMapDataset is used with load_neighbors=True and get_row_with_neighbor() returns tuples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch
|
List[Dict]
|
List of dictionaries, each containing: - 'current_cell': Tuple[np.ndarray, np.ndarray] (values, columns) - 'next_cell': Tuple[np.ndarray, np.ndarray] (values, columns) - 'current_cell_index': int - 'next_cell_index': int |
required |
Returns:
Type | Description |
---|---|
Dict[str, Union[Tensor, List[int], int]]
|
Dict containing: |
Dict[str, Union[Tensor, List[int], int]]
|
|
Dict[str, Union[Tensor, List[int], int]]
|
|
Dict[str, Union[Tensor, List[int], int]]
|
|
Dict[str, Union[Tensor, List[int], int]]
|
|
Dict[str, Union[Tensor, List[int], int]]
|
|
Source code in bionemo/scdl/util/torch_dataloader_utils.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
collate_sparse_matrix_batch(batch)
Collate function to create a batch out of sparse tensors.
This is necessary to collate sparse matrices of various lengths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch
|
list[Tensor]
|
A list of Tensors to collate into a batch. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
The tensors collated into a CSR (Compressed Sparse Row) Format. |
Source code in bionemo/scdl/util/torch_dataloader_utils.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|