Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix dataset split into train/val/test #675

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/schnetpack/data/splitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def random_split(dsize: int, *split_sizes: Union[int, float]) -> List[torch.tens

Args:
dsize - Size of dataset.
split_sizes - Sizes for each split. One can be set to -1 to assign all
remaining data. Values in [0, 1] can be used to give relative partition
split_sizes - Sizes for each split. One value can be set to None to assign all
remaining data. Values in [0, 1) can be used to give relative partition
sizes.
"""
split_sizes = absolute_split_sizes(dsize, split_sizes)
offsets = torch.cumsum(torch.tensor(split_sizes), dim=0)
indices = torch.randperm(sum(split_sizes)).tolist()
indices = torch.randperm(dsize).tolist()
partition_sizes_idx = [
indices[offset - length : offset]
for offset, length in zip(offsets, split_sizes)
Expand Down