Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

infer输出多个值

Open guozhizou opened this issue 8 years ago • 9 comments

aid = paddle.layer.data(name='aid',type=paddle.data_type.sparse_binary_vector(200))

.....

infer = paddle.inference.Inference(output_layer=[inference, label, aid, uid], parameters=parameters)

aid和uid是两个id类特征,被用来向量化。在infer的时候如果想要将这两个id类都输出,应该怎么做? 直接输出报错如下:

    res = infer.infer(input=batch, feeding=feeding, field=['value'])
  File "/home/disk0/tools/paddle/python27/lib/python2.7/site-packages/paddle/v2/inference.py", line 74, in infer
    for result in self.iter_infer_field(field=field, **kwargs):
  File "/home/disk0/tools/paddle/python27/lib/python2.7/site-packages/paddle/v2/inference.py", line 61, in iter_infer_field
    for result in self.iter_infer(**kwargs):
  File "/home/disk0/tools/paddle/python27/lib/python2.7/site-packages/paddle/v2/inference.py", line 54, in iter_infer
    yield self.__gradient_machine__.forwardTest(feeder(data_batch))
  File "/home/disk0/tools/paddle/python27/lib/python2.7/site-packages/py_paddle/util.py", line 153, in forwardTest
    for i in xrange(outArgs.getSlotNum())
  File "/home/disk0/tools/paddle/python27/lib/python2.7/site-packages/py_paddle/util.py", line 89, in __arguments_to_numpy__
    value = value.copyToNumpyMat()
  File "/home/disk0/tools/paddle/python27/lib/python2.7/site-packages/py_paddle/swig_paddle.py", line 631, in copyToNumpyMat
    return _swig_paddle.Matrix_copyToNumpyMat(self)
RuntimeError:

guozhizou avatar Apr 27 '18 12:04 guozhizou

@guozhizou 这里的label,aid, uid都不需要输入网络,然后从网络中返回,直接在模型外面使用就行了

kuke avatar Apr 28 '18 07:04 kuke

嗯,不输入网络是可以的。这里的两个id类都是作为特征使用,但是infer的时候也需要用到这两个id,这时候有什么办法解决吗?paddle v1是可以支持输出的

guozhizou avatar Apr 28 '18 07:04 guozhizou

@guozhizou id作为输入没有问题,如果不作为输出,输出output_layer=inference还会报错吗?

kuke avatar Apr 28 '18 08:04 kuke

不输出没问题的

guozhizou avatar Apr 28 '18 08:04 guozhizou

@guozhizou 好的,那就可以这么用了。可能是这几个data_layer直接作为Inference的输出导致的问题。

kuke avatar Apr 28 '18 08:04 kuke

呃,咋用。。。 两个id类作为输入特征,infer的时候也需要用到这两个id

guozhizou avatar Apr 28 '18 08:04 guozhizou

infer的时候用这两个id作为输入没问题,但没有必要作为输出。在模型外要用这两个id直接就可以用不是么?

kuke avatar Apr 28 '18 08:04 kuke

需求特殊。。 这里infer的时候这两个id既要作为输入,又要作为输出

guozhizou avatar Apr 28 '18 08:04 guozhizou

您好,此issue在近一个月内暂无更新,我们将于今天内关闭。若在关闭后您仍需跟进提问,可重新开启此问题,我们将在24小时内回复您。因关闭带来的不便我们深表歉意,请您谅解~感谢您对PaddlePaddle的支持! Hello, this issue has not been updated in the past month. We will close it today for the sake of other user‘s experience. If you still need to follow up on this question after closing, please feel free to reopen it. In that case, we will get back to you within 24 hours. We apologize for the inconvenience caused by the closure and thank you so much for your support of PaddlePaddle Group!

shanyi15 avatar Aug 15 '18 10:08 shanyi15