partition_dataset
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
調査の方向性
monai/data/utils.py の行 1217-1224 付近で partition_dataset が各パーティションのサイズを計算している丸めロジックを読み、issue 内のスニペットでバグを再現してください(例: partition_dataset(list(range(10)), ratios=[1,1,1]) が要素を落とす)。修正は、最も切り捨てられたパーティションに残余要素を分配するべきです。また、報告者は修正とテストを既に用意していると言っているため、PR が出現する可能性があるので、開始前に調整のために早急にコメントしてください。完了: 報告された ratios/lengths に対して各要素がちょうど1つのパーティションに収まり、tests for partition_dataset の既存のテストは引き続き通過し、新しいテストが残余要素のケースをカバーする。
索引モデルが issue の本文から書いたものです。
説明
When partition_dataset(data, ratios=...) splits a list, it computes every partition's size by rounding independently (see monai/data/utils.py, lines 1217–1224 at commit 6920610). If those rounded sizes add up to less than len(data), the extra items end up in no partition, and no warning or error is raised.
With three ratios this affects roughly one length in five: for 0.8/0.1/0.1 it happens for 200 of the lengths from 1 to 1000, and for 1/1/1 it happens for 334 of them. With five equal ratios, as many as two items can disappear. Because partition_dataset_classes applies the same function to each class, it can lose up to one item per class. Splits into two parts are not affected.
I found this by reading the code and then testing it.
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 thing occurs for other Decathlon training-set sizes. Examples: 303 cases (Task08_HepaticVessel) and 484 cases (Task01_BrainTumour) with 0.8/0.1/0.1; 63 and 303 cases with 0.7/0.15/0.15; and 32 cases (Task05_Prostate) with five equal ratios, where two cases are lost. 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
Each item should land in exactly one partition, as the docstring example shows ([0.6, 0.2, 0.2] on 5 items gives [[1, 2, 3], [4], [5]]). The documentation says drop_last does not apply when ratios are used.
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 ready. It hands the leftover items to the partitions that were rounded down the most, and splits that already cover every item stay unchanged. It comes with tests, and I can open a PR.
- 主要言語
- Python
- スター
- 8.8k
- フォーク
- 1.7k
- 平均マージ
- 5日 3時間
- マージ済み PR(30日)
- 13
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Project-MONAI/MONAI のほかの issue
-
partition_dataset with ratios leaves some items out of every partition対応中かも @mottopanikeiku が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Project-MONAI/MONAI#9216 ·
メンテナーはふだん 3 日以内に返信
-
FocalLoss mean reduction is multiplied by the number of channels when ignore_index is set対応中かも @mottopanikeiku が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Project-MONAI/MONAI#9214 ·
メンテナーはふだん 3 日以内に返信
-
DiNTS: missing graph-break regression test (follow-up to #9145)対応中かも @nilapate が 16 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
Project-MONAI/MONAI#9159 ·
メンテナーはふだん 3 日以内に返信
-
ProbMapProducer raises IndexError on numpy 2.x: SlidingPatchWSIDataset emits float locations対応中かも @nilapate が 27 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Project-MONAI/MONAI#9135 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
RandGridPatch crashes for documented 0 or None patch_size entries対応中かも @Rajioba1 が 84 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Project-MONAI/MONAI#9046 ·
メンテナーはふだん 3 日以内に返信
Project-MONAI/MONAI の issue をすべて見る
似ている issue
-
The changelog workflow excludes otelbot but not dependabot, so every Dependabot pull request fails the changelog check対応中かも @ocelotl が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
open-telemetry/opentelemetry-python#5825 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
cuga-project/cuga-agent#1020 ·
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
microsoft/playwright#43640 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
stac-utils/stac-fastapi-elasticsearch-opensearch#965 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信