mirror of
https://github.com/explosion/spaCy.git
synced 2025-09-20 02:52:45 +03:00
Deal with generators in tuplify
This commit is contained in:
parent
a7d9c8156d
commit
0620820857
|
@ -70,6 +70,10 @@ def tuplify(layer1: Model, layer2: Model, *layers) -> Model:
|
||||||
def tuplify_forward(model, X, is_train):
|
def tuplify_forward(model, X, is_train):
|
||||||
Ys = []
|
Ys = []
|
||||||
backprops = []
|
backprops = []
|
||||||
|
# If the input is a generator we need to unroll it.
|
||||||
|
# The type check is necessary because arrays etc. are also OK.
|
||||||
|
if isinstance(X, Generator):
|
||||||
|
X = list(X)
|
||||||
for layer in model.layers:
|
for layer in model.layers:
|
||||||
Y, backprop = layer(X, is_train)
|
Y, backprop = layer(X, is_train)
|
||||||
Ys.append(Y)
|
Ys.append(Y)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user