提交 2e527ad3 编写于 作者: T Tao Luo 提交者: GitHub

Merge pull request #2136 from luotao1/infer

add multiple outputs in annotation of paddle.infer
...@@ -88,7 +88,7 @@ def infer(output_layer, parameters, input, feeding=None, field='value'): ...@@ -88,7 +88,7 @@ def infer(output_layer, parameters, input, feeding=None, field='value'):
Infer a neural network by given neural network output and parameters. The Infer a neural network by given neural network output and parameters. The
user should pass either a batch of input data or reader method. user should pass either a batch of input data or reader method.
Example usages: Example usage for sinlge output_layer:
.. code-block:: python .. code-block:: python
...@@ -97,8 +97,19 @@ def infer(output_layer, parameters, input, feeding=None, field='value'): ...@@ -97,8 +97,19 @@ def infer(output_layer, parameters, input, feeding=None, field='value'):
input=SomeData) input=SomeData)
print result print result
Example usage for multiple outout_layers and fields:
.. code-block:: python
result = paddle.infer(output_layer=[prediction1, prediction2],
parameters=parameters,
input=SomeData,
field=[id, value]])
print result
:param output_layer: output of the neural network that would be inferred :param output_layer: output of the neural network that would be inferred
:type output_layer: paddle.v2.config_base.Layer :type output_layer: paddle.v2.config_base.Layer or a list of
paddle.v2.config_base.Layer
:param parameters: parameters of the neural network. :param parameters: parameters of the neural network.
:type parameters: paddle.v2.parameters.Parameters :type parameters: paddle.v2.parameters.Parameters
:param input: input data batch. Should be a python iterable object, and each :param input: input data batch. Should be a python iterable object, and each
...@@ -112,7 +123,9 @@ def infer(output_layer, parameters, input, feeding=None, field='value'): ...@@ -112,7 +123,9 @@ def infer(output_layer, parameters, input, feeding=None, field='value'):
Note that `prob` only used when output_layer is beam_search Note that `prob` only used when output_layer is beam_search
or max_id. or max_id.
:type field: str :type field: str
:return: a numpy array :return: The prediction result. If there are multiple outout_layers and fields,
the return order is outout_layer1.field1, outout_layer2.field1, ...,
outout_layer1.field2, outout_layer2.field2 ...
:rtype: numpy.ndarray :rtype: numpy.ndarray
""" """
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册