Fetch item by index and a dynamic variable n_per_seq.
(self, idx_N)
| 206 | return len(self.metadata[sequence_name]) |
| 207 | |
| 208 | def __getitem__(self, idx_N): |
| 209 | """Fetch item by index and a dynamic variable n_per_seq.""" |
| 210 | |
| 211 | # Different from most pytorch datasets, |
| 212 | # here we not only get index, but also a dynamic variable n_per_seq |
| 213 | # supported by DynamicBatchSampler |
| 214 | |
| 215 | index, n_per_seq = idx_N |
| 216 | sequence_name = self.sequence_list[index] |
| 217 | metadata = self.metadata[sequence_name] |
| 218 | ids = np.random.choice(len(metadata), n_per_seq, replace=False) |
| 219 | return self.get_data(index=index, ids=ids) |
| 220 | |
| 221 | def get_data( |
| 222 | self, |