partition_dataset
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
Línea de trabajo
Lee la lógica de redondeo en monai/data/utils.py alrededor de las líneas 1217-1224 donde partition_dataset calcula el tamaño de cada partición, y reproduce el error con el fragmento del issue (p. ej. partition_dataset(list(range(10)), ratios=[1,1,1]) descarta elementos). La corrección debe distribuir los elementos sobrantes a las particiones redondeadas hacia abajo en mayor medida, y el informador dice que tiene una corrección y tests listos — comenta rápidamente para coordinar antes de empezar, ya que puede aparecer un PR. Hecho: cada elemento cae en exactamente una partición para los ratios/lengths reportados, los tests existentes en tests for partition_dataset siguen pasando, y nuevos tests cubren los casos de elementos sobrantes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 8.8k
- Forks
- 1.7k
- Merge medio
- 5 d 3 h
- PR fusionados (30 d)
- 13
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Project-MONAI/MONAI
-
partition_dataset with ratios leaves some items out of every partitionPosiblemente ocupada @mottopanikeiku la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Project-MONAI/MONAI#9216 ·
Los mantenedores suelen responder en 3 días
-
FocalLoss mean reduction is multiplied by the number of channels when ignore_index is setPosiblemente ocupada @mottopanikeiku la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Project-MONAI/MONAI#9214 ·
Los mantenedores suelen responder en 3 días
-
DiNTS: missing graph-break regression test (follow-up to #9145)Posiblemente ocupada @nilapate la tomó hace 17 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Project-MONAI/MONAI#9159 ·
Los mantenedores suelen responder en 3 días
-
ProbMapProducer raises IndexError on numpy 2.x: SlidingPatchWSIDataset emits float locationsPosiblemente ocupada @nilapate la tomó hace 28 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Project-MONAI/MONAI#9135 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
RandGridPatch crashes for documented 0 or None patch_size entriesPosiblemente ocupada @Rajioba1 la tomó hace 85 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Project-MONAI/MONAI#9046 ·
Los mantenedores suelen responder en 3 días
Todos los issues de Project-MONAI/MONAI
Issues similares
-
Web transport: small test gapsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
scikit-learn-contrib/category_encoders#553 ·
Los mantenedores suelen responder en 1 día
-
tests/strategies_test.py:174 goes uncovered on about 1 run in 100, failing the coverage ratchetAbiertoflaky-watch
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
btclib-org/btclib#2839 ·
Los mantenedores suelen responder en 1 día
-
BarrelList constructor drops false-valued iterable contentsPosiblemente ocupada @Gambit-Checkmate la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 19 días
-
[Performance]: Redundant object-storage pull when model and tokenizer share the same RunAI URIAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
vllm-project/vllm#63863 ·
Los mantenedores suelen responder en 1 día