Multiple infer output must have the same size ?
Created by: pengwangucla
related to issue #2107 (closed) In paddle.infer, it concatenate different output of the same field as follow:
def infer(self, input, field='value', **kwargs):
"""
Infer a data by model.
:param input: input data batch. Should be python iterable object.
:param field: output field.
"""
retv = None
kwargs['input'] = input
for result in self.iter_infer_field(field=field, **kwargs):
if retv is None:
retv = [[] for i in xrange(len(result))]
for i, item in enumerate(result):
retv[i].append(item)
> retv = [numpy.concatenate(out) for out in retv]
if len(retv) == 1:
return retv[0]
else:
return retv
Why you need to concatenate it ? Can it be done with a 2 d list or a list of dictionary ? So that you don't need to require the shape of each output to be exactly the same ?
@reyoung