mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-12 02:06:31 +03:00
Fix spacy.util.minibatch
when the size iterator is finished (#6745)
This commit is contained in:
parent
e649242927
commit
28256522c8
|
@ -513,7 +513,7 @@ def minibatch(items, size=8):
|
||||||
size_ = size
|
size_ = size
|
||||||
items = iter(items)
|
items = iter(items)
|
||||||
while True:
|
while True:
|
||||||
batch_size = next(size_)
|
batch_size = next(size_, 0) # StopIteration isn't handled in generators in Python >= 3.7.
|
||||||
batch = list(itertools.islice(items, int(batch_size)))
|
batch = list(itertools.islice(items, int(batch_size)))
|
||||||
if len(batch) == 0:
|
if len(batch) == 0:
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue
Block a user