Error loading topology file generated by book/fit_a_line.py 不能正确load图结构文件
Created by: rulai-huiyingl
I used the following code to load the graph topology file generated by fit_a_line.py
import paddle.v2 as paddle
params = paddle.parameters.Parameters.from_tar(open('params_pass_0.tar'))
inferer = paddle.inference.Inference(parameters=params, fileobj=open('inference_topology.pkl'))
and the output is as follows:
WARNING: Logging before InitGoogleLogging() is written to STDERR
F1206 19:09:04.177959 21204 ClassRegistrar.h:65] Check failed: mapGet(type, creatorMap_, &creator) Unknown class type: data
*** Check failure stack trace: ***
Aborted (core dumped)
I wrote the code following the instruction in paddle/v2/inference.py:
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)
:param output_layer: The neural network that should be inferenced.
:type output_layer: paddle.v2.config_base.Layer or the sequence
of paddle.v2.config_base.Layer
:param parameters: The parameters dictionary.
:type parameters: paddle.v2.parameters.Parameters
"""
def __init__(self, parameters, output_layer=None, fileobj=None):
import py_paddle.swig_paddle as api
if output_layer is not None:
topo = topology.Topology(output_layer)
gm = api.GradientMachine.createFromConfigProto(
topo.proto(), api.CREATE_MODE_TESTING, [api.PARAMETER_VALUE])
self.__data_types__ = topo.data_type()
elif fileobj is not None:
tmp = cPickle.load(fileobj)
gm = api.GradientMachine.createByConfigProtoStr(
tmp['protobin'], api.CREATE_MODE_TESTING,
[api.PARAMETER_VALUE])
self.__data_types__ = tmp['data_type']
else:
raise ValueError("Either output_layer or fileobj must be set")
...
Could you please let me know where I did wrong that the topology file won't load? Same issue with topology file saved by other paddle programs I wrote.... Thank you! 多谢多谢!