Data¶
Dataset handling and data loading utilities.
DataGroup¶
DataGroup(data=None, keys=None, shard=None)
¶
Dict-like container for data arrays with consistent shape.
Args:
data (str | Dict[str, np.ndarray] | None): The data to be used in the dataset.
It can be a string representing the path to the data file in NPZ format or a dictionary where
keys are strings and values are numpy arrays.
keys (List[str] | None): A list of keys to be used from the data dictionary.
shard (Tuple[int, int] | None): A tuple representing the shard index and total shards.
Source code in aimnet/data/sgdataset.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
cv_split(cv=5, seed=None)
¶
Return list of cv tuples containing train and val DataGroups
Source code in aimnet/data/sgdataset.py
127 128 129 130 131 132 133 134 135 136 137 138 139 | |
merge(other, strict=True)
¶
Concatenate other into this group along the sample axis.
With strict=True both groups must carry exactly the same data keys.
With strict=False the result keeps only the keys they share: keys
present here but missing from other are dropped. Keys present in
other but missing here are ignored in both modes -- this only ever
grows the sample axis, never the key set. other is not modified.
Source code in aimnet/data/sgdataset.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
rename_key(old, new)
¶
Rename data key old to new in place.
Source code in aimnet/data/sgdataset.py
104 105 106 | |
sample(idx, keys=None)
¶
Return a new DataGroup with the data indexed by idx.
Source code in aimnet/data/sgdataset.py
108 109 110 111 112 113 114 | |
to_dict()
¶
Return the live {key: array} mapping backing this group.
This is the internal dict, not a copy: mutating it mutates the group.
Source code in aimnet/data/sgdataset.py
85 86 87 88 89 90 | |
SizeGroupedDataset¶
SizeGroupedDataset(data=None, keys=None, shard=None)
¶
Source code in aimnet/data/sgdataset.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
merge(other, strict=True)
¶
Merge other into this dataset in place.
Size groups present in both are concatenated; groups only in other
are adopted as-is. With strict=True both datasets must carry exactly
the same data keys.
Two side effects to be aware of, both long-standing:
- With
strict=False,otheris also reduced in place to the shared key set. Pass a copy if you still need it intact. - An adopted group is taken by reference, not copied, so that group is then shared between the two datasets.
Source code in aimnet/data/sgdataset.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
rename_datakey(old, new)
¶
Rename data key old to new across every size group.
Source code in aimnet/data/sgdataset.py
293 294 295 296 | |
SizeGroupedSampler¶
SizeGroupedSampler(ds, batch_size, batch_mode='molecules', shuffle=False, batches_per_epoch=-1, seed=None)
¶
Source code in aimnet/data/sgdataset.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 | |