You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm thinking of using PyDataset but trying to understand first from first principles (before just testing) whether it makes sense to use a certain number of workers.
Here is an example from the docs:
//skipimportsforbrevityclassCIFAR10PyDataset(keras.utils.PyDataset):
def__init__(self, x_set, y_set, batch_size, **kwargs):
super().__init__(**kwargs)
self.x, self.y=x_set, y_setself.batch_size=batch_sizedef__len__(self):
# Return number of batches.returnmath.ceil(len(self.x) /self.batch_size)
def__getitem__(self, idx):
# Return x, y for batch idx.low=idx*self.batch_size# Cap upper bound at array length; the last batch may be smaller# if the total number of items is not a multiple of batch size.high=min(low+self.batch_size, len(self.x))
batch_x=self.x[low:high]
batch_y=self.y[low:high]
returnnp.array([
resize(imread(file_name), (200, 200))
forfile_nameinbatch_x]), np.array(batch_y)
I'd guess that in this case the main reason to use multithreading and several workers would be to get a fast resizing but otherwise the operation will mostly involve I/O operations and not CPU processing.
So data-loading when a bit of processing is done to the data would be a good use case for multi threading & workers ? And what about a reasonable number of workers? Is there a way to know the maximum available?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm thinking of using
PyDataset
but trying to understand first from first principles (before just testing) whether it makes sense to use a certain number of workers.Here is an example from the docs:
I'd guess that in this case the main reason to use multithreading and several workers would be to get a fast
resizing
but otherwise the operation will mostly involve I/O operations and not CPU processing.So data-loading when a bit of processing is done to the data would be a good use case for multi threading & workers ? And what about a reasonable number of workers? Is there a way to know the maximum available?
Beta Was this translation helpful? Give feedback.
All reactions