|
|
|
@ -12,9 +12,9 @@ class Inference(object):
|
|
|
|
|
"""
|
|
|
|
|
Inference combines neural network output and parameters together
|
|
|
|
|
to do inference.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inferer = Inference(output_layer=prediction, parameters=parameters)
|
|
|
|
|
for data_batch in batches:
|
|
|
|
|
print inferer.infer(data_batch)
|
|
|
|
@ -92,8 +92,8 @@ def infer(output_layer, parameters, input, feeding=None, field='value'):
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
result = paddle.infer(output_layer=prediction,
|
|
|
|
|
parameters=parameters,
|
|
|
|
|
result = paddle.infer(output_layer=prediction,
|
|
|
|
|
parameters=parameters,
|
|
|
|
|
input=SomeData)
|
|
|
|
|
print result
|
|
|
|
|
|
|
|
|
@ -101,14 +101,14 @@ def infer(output_layer, parameters, input, feeding=None, field='value'):
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
result = paddle.infer(output_layer=[prediction1, prediction2],
|
|
|
|
|
parameters=parameters,
|
|
|
|
|
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
|
|
|
|
|
:type output_layer: paddle.v2.config_base.Layer or a list of
|
|
|
|
|
:type output_layer: paddle.v2.config_base.Layer or a list of
|
|
|
|
|
paddle.v2.config_base.Layer
|
|
|
|
|
:param parameters: parameters of the neural network.
|
|
|
|
|
:type parameters: paddle.v2.parameters.Parameters
|
|
|
|
@ -117,14 +117,14 @@ def infer(output_layer, parameters, input, feeding=None, field='value'):
|
|
|
|
|
:type input: collections.Iterable
|
|
|
|
|
:param feeding: Reader dictionary. Default could generate from input
|
|
|
|
|
value.
|
|
|
|
|
:param field: The prediction field. It should in [`value`, `id`, `prob`].
|
|
|
|
|
`value` and `prob` mean return the prediction probabilities,
|
|
|
|
|
:param field: The prediction field. It should in [`value`, `id`, `prob`].
|
|
|
|
|
`value` and `prob` mean return the prediction probabilities,
|
|
|
|
|
`id` means return the prediction labels. Default is `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.
|
|
|
|
|
:type field: str
|
|
|
|
|
:return: The prediction result. If there are multiple outout_layers and fields,
|
|
|
|
|
the return order is outout_layer1.field1, outout_layer2.field1, ...,
|
|
|
|
|
: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
|
|
|
|
|
"""
|
|
|
|
|