Skip to content

Inconsistent StopIteration error related to batch size vs. training dataset size across datasets #10

@imb-ai-junghwan

Description

@imb-ai-junghwan

Hi,
Based on my previous experience, I understood that the StopIteration error was related to the relationship between the training dataset size and the batch size. Specifically, when the training dataset size was smaller than 64, I set the batch size to 16 (a modified option), and for larger datasets I used the default batch size. This approach had worked reliably for me in the past.
However, when running experiments on a total of 36 datasets this time, the behavior was no longer consistent with what I expected. Even though I applied the same rule as before, some datasets completed successfully while others failed with a StopIteration error.
At this point, I cannot identify a clear pattern that explains why certain datasets succeed and others fail under the same batch size logic.
I would appreciate any insight into:

What underlying conditions might cause this inconsistent behavior

Whether there are additional factors beyond dataset size that could trigger this error

Recommended best practices for setting batch size in relation to dataset size to avoid StopIteration
I will include the details of my datasets and the error messages below.

Thank you for your help.

Dataset and results:
Dataset | N_healthy_train | N_disease_train | N_healthy_test | N_disease_test | N_train | N_test | GDmicro Option | Run
1 | 66 | 97 | 8 | 11 | 163 | 19 | default | Fail
2 | 497 | 34 | 56 | 4 | 531 | 60 | default | Fail
3 | 57 | 135 | 7 | 16 | 192 | 23 | default | Fail
4 | 49 | 60 | 6 | 7 | 109 | 13 | default | Fail
5 | 57 | 75 | 7 | 9 | 132 | 16 | default | Fail
6 | 262 | 60 | 30 | 7 | 322 | 37 | default | Fail
7 | 279 | 33 | 32 | 4 | 312 | 36 | default | Fail
8 | 187 | 188 | 21 | 21 | 375 | 42 | default | Fail
9 | 262 | 257 | 30 | 29 | 519 | 59 | default | Fail
10 | 279 | 266 | 32 | 30 | 545 | 62 | default | Fail
11 | 78 | 75 | 9 | 9 | 153 | 18 | default | Fail
12 | 48 | 66 | 6 | 8 | 114 | 14 | default | Fail
13 | 164 | 168 | 19 | 19 | 332 | 38 | default | Fail
14 | 94 | 136 | 11 | 16 | 230 | 27 | default | Fail
15 | 193 | 312 | 22 | 35 | 505 | 57 | default | Fail
16 | 87 | 85 | 10 | 10 | 172 | 20 | default | Fail
17 | 86 | 89 | 10 | 10 | 175 | 20 | default | Fail
18 | 135 | 57 | 16 | 7 | 192 | 23 | default | Fail
19 | 153 | 192 | 18 | 22 | 345 | 40 | default | Fail
20 | 128 | 148 | 15 | 17 | 276 | 32 | default | Fail
21 | 90 | 67 | 10 | 8 | 157 | 18 | default | Fail
22 | 497 | 195 | 56 | 22 | 692 | 78 | default | Success
23 | 56 | 42 | 7 | 5 | 98 | 12 | default | Success
24 | 56 | 41 | 7 | 5 | 97 | 12 | default | Success
25 | 27 | 27 | 3 | 3 | 54 | 6 | modified | Success
26 | 36 | 35 | 4 | 4 | 71 | 8 | default | Success
27 | 23 | 23 | 3 | 3 | 46 | 6 | modified | Success
28 | 18 | 16 | 2 | 2 | 34 | 4 | modified | Success
29 | 19 | 38 | 3 | 5 | 57 | 8 | modified | Success
30 | 27 | 38 | 4 | 5 | 65 | 9 | default | Success
31 | 38 | 44 | 5 | 5 | 82 | 10 | default | Success
32 | 16 | 17 | 2 | 2 | 33 | 4 | modified | Success
33 | 38 | 46 | 5 | 6 | 84 | 11 | default | Success
34 | 27 | 28 | 3 | 4 | 55 | 7 | modified | Success
35 | 9 | 12 | 2 | 2 | 21 | 4 | modified | Success
36 | 46 | 37 | 6 | 5 | 83 | 11 | default | Success

Error message:
Traceback (most recent call last):
File "./GDmicro/run_MLP_embedding_da.py", line 224, in build_graph_mlp
tgt_data,_=tgt_iter.next()
File "./gdmicro/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 652, in next
data = self._next_data()
File "./gdmicro/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 691, in _next_data
index = self._next_index() # may raise StopIteration
File "./gdmicro/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 642, in _next_index
return next(self._sampler_iter) # may raise StopIteration
StopIteration

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions