mxnet.image.ImageIter - how to know where data stops in last batch before raise of StopIteration?


#1

Hi all,

I tried to build two custom iterators, the one based on ImageIter had the problem that on the last batch before raise stopiteration at some point contained bogus data. how to know when in the last batch the good data ends and the bogus data starts?

Regards, Alex


#2

Hi @alexthegreyhorse

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

Vishaal