zhreshold commented on a change in pull request #12131: [MXNET-737][WIP] Add
last batch handle for imageiter
URL: https://github.com/apache/incubator-mxnet/pull/12131#discussion_r210980448
##########
File path: python/mxnet/image/image.py
##########
@@ -1149,22 +1155,49 @@ def __init__(self, batch_size, data_shape,
label_width=1,
else:
self.auglist = aug_list
self.cur = 0
+ self._is_allowed_reading = True
+ self.last_batch_handle = last_batch_handle
+ self.num_image = len(self.seq) if self.seq is not None else None
+ self._cache_data = None
+ self._cache_label = None
+ self._cache_idx = None
self.reset()
def reset(self):
"""Resets the iterator to the beginning of the data."""
- if self.shuffle:
+ if self.seq is not None and self.shuffle:
+ random.shuffle(self.seq)
+ if self.last_batch_handle != 'roll_over' or \
+ self._cache_data is None:
+ if self.imgrec is not None:
+ self.imgrec.reset()
+ self.cur = 0
+ if self._is_allowed_reading is False:
+ self._is_allowed_reading = True
+
+ def hard_reset(self):
+ """Resets the iterator and ignore roll over data"""
+ if self.seq is not None and self.shuffle:
random.shuffle(self.seq)
if self.imgrec is not None:
self.imgrec.reset()
self.cur = 0
+ self._is_allowed_reading = True
Review comment:
`self._allow_read` for shorter but same meaning
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services