-
Notifications
You must be signed in to change notification settings - Fork 130
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
extend DummyDatasetMultipleSequenceLength #492
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -729,6 +729,7 @@ def __init__(self, input_dim, output_dim, num_seqs, seq_len=None, | |
""" | ||
if seq_len is None: | ||
seq_len = {'data': 10, 'classes': 20} | ||
self._seq_order = None # type: typing.Optional[typing.List[int]] | ||
super(DummyDatasetMultipleSequenceLength, self).__init__( | ||
input_dim=input_dim, | ||
output_dim=output_dim, | ||
|
@@ -756,6 +757,34 @@ def generate_seq(self, seq_idx): | |
for i in range(i1, i2)]) | ||
return DatasetSeq(seq_idx=seq_idx, features=features, targets=targets) | ||
|
||
def get_all_tags(self): | ||
""" | ||
:rtype: list[str] | ||
""" | ||
return ["seq-%i" % i for i in range(self._num_seqs)] | ||
|
||
def init_seq_order(self, epoch=None, seq_list=None, seq_order=None): | ||
""" | ||
If random_shuffle_epoch1, for epoch 1 with "random" ordering, we leave the given order as is. | ||
Otherwise, this is mostly the default behavior. | ||
|
||
:param int|None epoch: | ||
:param list[str]|None seq_list: List of sequence tags, to set a predefined order. | ||
:param list[int]|None seq_order: List of corpus sequence indices, to set a predefined order. | ||
:rtype: bool | ||
:returns whether the order changed (True is always safe to return) | ||
""" | ||
super(DummyDatasetMultipleSequenceLength, self).init_seq_order(epoch=epoch, seq_list=seq_list, seq_order=seq_order) | ||
|
||
def get_seq_len(i): | ||
return self.seq_len['data'] | ||
|
||
self._seq_order = self.get_seq_order_for_epoch(epoch, self._num_seqs, get_seq_len=get_seq_len) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this makes sense to support for this dataset. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By support, I mean |
||
self._num_seqs = len(self._seq_order) | ||
|
||
def get_current_seq_order(self): | ||
return self._seq_order | ||
|
||
|
||
class DummyDatasetMultipleDataKeys(DummyDataset): | ||
""" | ||
|
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.
self._num_seqs
might beinf
. It should handle that correctly (fall back to the default behavior).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.
What is the default behaviour?
Does it even make sense for a dummy dataset to be initialized with
num_seqs=inf
?In
GeneratingDataset
it is per defaultinf
but here it has to be set by the user.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.
Whatever
super
of this function does. Just check the code.Yes it does. Why not? It's usually only used for testing. In any case, this is explicitly supported.