loop instead of any

This commit is contained in:
svlandeg 2021-02-12 13:14:30 +01:00
parent 278e9eaa14
commit aa3ad8825d

View File

@ -291,14 +291,16 @@ def forward(model: Tok2VecListener, inputs, is_train: bool):
# of data. # of data.
# When the components batch differently, we don't receive a matching # When the components batch differently, we don't receive a matching
# prediction from the upstream, so we can't predict. # prediction from the upstream, so we can't predict.
if not any(doc.tensor.size for doc in inputs): outputs = []
# But we do need to do *something* if the tensor hasn't been set. width = model.get_dim("nO")
# The compromise is to at least return data of the right shape, for doc in inputs:
# so the output is valid. if doc.tensor.size == 0:
width = model.get_dim("nO") # But we do need to do *something* if the tensor hasn't been set.
outputs = [model.ops.alloc2f(len(doc), width) for doc in inputs] # The compromise is to at least return data of the right shape,
else: # so the output is valid.
outputs = [doc.tensor for doc in inputs] outputs.append(model.ops.alloc2f(len(doc), width))
else:
outputs.append(doc.tensor)
return outputs, lambda dX: [] return outputs, lambda dX: []