-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TileDataset #63
base: master
Are you sure you want to change the base?
Add TileDataset #63
Conversation
iterable = self.input_dataset.__iter__(with_key=True) | ||
else: | ||
iterable = self.input_dataset | ||
for example in iterable: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use yield from
?
item = item + len(self) | ||
if item < 0: | ||
raise IndexError(_item) | ||
if item > self.repetitions * len(self.input_dataset): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use len(self)
?
Does the following code works? import lazy_dataset
ds = lazy_dataset.new([1, 2, 3])
ds = ds.shuffle(reshuffle=True)
ds = ds.tile(4).catch()
list(ds) We have to handle the combination of non-ordered (e.g. reshuffle), tile, copy(freeze) and indexing. I see two solutions:
|
""" | ||
if isinstance(item, str): | ||
return self.input_dataset[item] | ||
elif isinstance(item, numbers.Integral): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, whether this code will have an effect in the performance.
How about changing the code to the follwing?
input_len = len(self.input_dataset)
if not (-self.repetitions <= item // input_len < self.repetitions):
raise IndexError(_item)
return self.input_dataset[item % input_len]
|
||
""" | ||
|
||
def __init__(self, input_dataset, repetitions): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rename repetitions
to reps
?
I prefer to have names close to numpy. (We don't want to do the same as pytorch, where you have to learn the new names for arguments, because they differ to numpy)
datasets = [ds.shuffle() for ds in datasets] | ||
return self.__class__.concatenate(*datasets) | ||
else: | ||
return TileDataset(self, reps) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To minimize overhead: Could your return self, when reps is one? concatenate does this already.
TileDataset should be more efficient than concatenating the input dataset for large
repetitions
(in my case in the 1000s)