partition_dataset with ratios leaves some items out of every partition
Maintainer thường phản hồi trong vòng 3 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- data, machine-learning
Hướng nghiên cứu
Bắt đầu tại monai/data/utils.py, ở partition_dataset và phần tính kích thước dựa trên tỷ lệ quanh các dòng được liên kết; đồng thời kiểm tra đường xử lý liên quan partition_dataset_classes. Tái hiện trường hợp thiếu mục đã được báo cáo, sau đó chạy hoặc bổ sung các bài kiểm thử tập trung cho phép chia theo tỷ lệ và phép chia theo lớp. Công việc hoàn tất khi mỗi mục đầu vào xuất hiện trong đúng một phân vùng, kể cả khi kích thước sau khi làm tròn có thể khiến một số mục bị bỏ sót.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
The text below was written with AI assistance (Claude and GPT-6 Astra).
partition_dataset(data, ratios=...) rounds each partition size on its own (https://github.com/Project-MONAI/MONAI/blob/6920610c310200d683a3b00987a05893ccf1ca5f/monai/data/utils.py#L1217-L1224). When the rounded sizes add up to less than len(data), the remaining items are not in any partition, and nothing reports it. With three ratios this happens for about one length in five (0.8/0.1/0.1: 200 of the lengths 1 to 1000; 1/1/1: 334), and with five equal ratios up to two items are lost. partition_dataset_classes splits each class with the same function, so it can lose one item per class. Two-way splits are not affected.
I found this by reading and testing the code.
To Reproduce
from monai.data import partition_dataset
print(partition_dataset(list(range(10)), ratios=[1, 1, 1]))
data = list(range(63)) # e.g. the 63 training cases of MSD Task06_Lung
train, val, test = partition_dataset(data, ratios=[0.8, 0.1, 0.1], shuffle=True, seed=0)
print(len(train), len(val), len(test), "in no split:", sorted(set(data) - set(train + val + test)))
Output on dev (6920610):
[[0, 1, 2], [3, 4, 5], [6, 7, 8]]
50 6 6 in no split: [44]
The same happens for other Decathlon training-set sizes, e.g. 303 (Task08_HepaticVessel) and 484 (Task01_BrainTumour) with 0.8/0.1/0.1, 63 and 303 with 0.7/0.15/0.15, and 32 (Task05_Prostate) with five equal ratios, which loses two cases. In a Decathlon-style pipeline (load_decathlon_datalist -> partition_dataset -> CacheDataset -> DataLoader) with 63 cases, one case is never loaded by the train, validation or test split.
Expected behavior
Every item should be in exactly one partition, as in the docstring example ([0.6, 0.2, 0.2] on 5 items gives [[1, 2, 3], [4], [5]]). drop_last is documented as not applying to the ratio path.
Environment
MONAI 1.6.1rc0+50.g6920610c (dev), PyTorch 2.14.1+cpu, NumPy 2.5.4, Python 3.12.13, Linux.
Additional context
I have a small fix that gives the leftover items to the partitions whose sizes were rounded down the most and leaves every split that already covers all items unchanged, plus tests, and can open a PR.
I made this report and directed the investigation, with AI assistance from Claude and GPT-6 Astra.
- Ngôn ngữ chính
- Python
- Star
- 8.8k
- Fork
- 1.7k
- Merge trung bình
- 5 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 13
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Project-MONAI/MONAI
-
partition_datasetĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Project-MONAI/MONAI#9220 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
FocalLoss mean reduction is multiplied by the number of channels when ignore_index is setCó thể đã có người làm @mottopanikeiku đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Project-MONAI/MONAI#9214 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
DiNTS: missing graph-break regression test (follow-up to #9145)Có thể đã có người làm @nilapate đã nhận 17 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Project-MONAI/MONAI#9159 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
ProbMapProducer raises IndexError on numpy 2.x: SlidingPatchWSIDataset emits float locationsCó thể đã có người làm @nilapate đã nhận 27 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Project-MONAI/MONAI#9135 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
RandGridPatch crashes for documented 0 or None patch_size entriesCó thể đã có người làm @Rajioba1 đã nhận 84 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Project-MONAI/MONAI#9046 ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của Project-MONAI/MONAI
Issue tương tự
-
request-theme
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 66/100
LizardByte/ThemerrDB#9575 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Author Page: noshin-nawalĐang mởauthor-page correction
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
acl-org/acl-anthology#10599 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
zilliztech/memsearch#818 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[FAQ] Commit ID for ProjectsCó thể đã có người làm @github-actions đã nhận hôm nay. Đang mởfaq-proposal
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
DataTalksClub/faq#503 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
README.zh-CN/ja/es still hard-code 501 test counts after README.md went count-freeCó thể đã có người làm @Aaqibhafeezkhan đã nhận hôm nay. Đang mởbeginner documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
BistaDinesh03/critique#164 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày