Inconsistent Outputs from BucketIterator

I’m getting some odd behavior from the BucketIterator.

I have a dataset of size 2164 split into 136 batches of 16. But on some random occasions it sends a batch size of only 4 through(presumably the last batch) too early. I’ve run the script several times and so far it’s pretty random as to when it happens. Once it did so on iter #103, another time on #118, another time on #124. And the odd thing is I have shuffle set to None, so the error “should” at least be consistent. The data isn’t changing. It seems to be randomly skipping certain batches.

Any idea what could be causing this or is this a known issue? The size of each sequence is set to fix_length=1100.

So I changed it to the Iterator class. Apparently BucketIterator implicitly randomizes batches via pool.