There are several options for the last batch from ImageIter. The default is ‘pad’ which adds data from the beginning to pad the last batch. That was likely the bogus data you were seeing. The easiest way around this would be to ‘discard’, or ‘roll_over’.
last_batch_handle ( str , optional ) – How to handle the last batch. This parameter can be ‘pad’(default), ‘discard’ or ‘roll_over’. If ‘pad’, the last batch will be padded with data starting from the begining If ‘discard’, the last batch will be discarded If ‘roll_over’, the remaining elements will be rolled over to the next iteration