Skip to content

Commit

Permalink
Fixed Dataset.subset when buffer_size is None
Browse files Browse the repository at this point in the history
  • Loading branch information
varisd committed Apr 23, 2019
1 parent 056df1d commit 0e1557a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion neuralmonkey/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,12 @@ def subset(self, start: int, length: int) -> "Dataset":
start, start + length)
for s_id in self.iterators}

# Workaround since self.buffer_size and self.buffer_min_size
# may not be initialized
buffer_size = None
if hasattr(self, "buffer_min_size") and hasattr(self, "buffer_size"):
buffer_size = (self.buffer_min_size, self.buffer_size)

# Here, the type: ignore is because of the tied argument to the lambda
# function above, which made it Callable[[Any], ...] instead of just
# Callable[[], ...].
Expand All @@ -610,5 +616,5 @@ def subset(self, start: int, length: int) -> "Dataset":
iterators=slices,
batching=self.batching,
outputs=outputs,
buffer_size=self.buffer_size,
buffer_size=buffer_size,
shuffled=self.shuffled)

0 comments on commit 0e1557a

Please sign in to comment.