Fetch item by index and a dynamic variable n_per_seq.
(self, idx_N)
| 63 | return len(self.metadata[sequence_name]) |
| 64 | |
| 65 | def __getitem__(self, idx_N): |
| 66 | """Fetch item by index and a dynamic variable n_per_seq.""" |
| 67 | |
| 68 | # Different from most pytorch datasets, |
| 69 | # here we not only get index, but also a dynamic variable n_per_seq |
| 70 | # supported by DynamicBatchSampler |
| 71 | |
| 72 | index, n_per_seq = idx_N |
| 73 | sequence_name = self.sequence_list[index] |
| 74 | metadata = self.metadata[sequence_name] |
| 75 | ids = np.random.choice(len(metadata), n_per_seq, replace=False) |
| 76 | return self.get_data(index=index, ids=ids) |
| 77 | |
| 78 | def get_data( |
| 79 | self, |