Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

python save_inference_model可以正常运行,但是__model__文件里有错误

Open shuoyin opened this issue 7 years ago • 2 comments

我使用python的save_inference_model接口保存模型,然后打开文件夹下的__model__文件,发现里边有错误信息,但是在python里可以正常save和load Paddle 1.4, CPU, python2 代码如下:

import paddle.fluid as fluid
import numpy as np 

data = np.random.rand(4,10).astype('float32')

x = fluid.layers.data(shape=[-1,10], name='x')
y = fluid.layers.fc(input=x, size=2)

place = fluid.CPUPlace()
exe = fluid.Executor(place)

exe.run(fluid.default_startup_program())
print exe.run(fluid.default_main_program(), feed={'x':data}, fetch_list=[y])

fluid.io.save_inference_model('test_save', ['x'], [y], exe)

print 'load inference'
inf_prog, feed, fetch = fluid.io.load_inference_model('test_save', exe)
print feed, fetch
print exe.run(inf_prog, feed={feed[0]:data}, fetch_list=fetch)

test_save文件夹里的__model__文件打开后里边有一些这样的错误 image 文件夹内容如下: image 谢谢!

shuoyin avatar May 22 '19 13:05 shuoyin

看起来貌似里边加了一些python backtrace信息,我之前也有发现过几次,不过对模型使用没有影响。这个问题我会及时反馈给相应的同学。

============ 补充:

模型的protobuf文件,中每个op会有一个 op_callstack 一个属性,其中保存了python端的一些log信息,此类信息产生了迷惑性(比如认为生成的模型是错误的)以及带来一定的冗余。

attrs {
  name: "op_callstack"
  type: STRINGS
  strings: "  File \"/home/users//.jumbo/lib/python2.7/site-packages/paddle/fluid/framework.py\", line 1380, in append_op\n    attrs=kwargs.get(\"attrs\", None))\n"
  strings: "  File \"/home/users//.jumbo/lib/python2.7/site-packages/paddle/fluid/layer_helper.py\", line 43, in append_op\n    return self.main_program.current_block().append_op(*args, **kwargs)\n"
  strings: "  File \"/home/users//.jumbo/lib/python2.7/site-packages/paddle/fluid/layers/nn.py\", line 2027, in conv2d\n    \'fuse_relu_before_depthwise_conv\': False\n"
  strings: "  File \"/home/users/tmp/face_detection_faceboxes/pyramidbox.py\", line 50, in conv_bn_layer\n    bias_attr=False)\n"
  strings: "  File \"/home/users/tmp/face_detection_faceboxes/pyramidbox.py\", line 99, in inceptionA\n    conv4 = conv_bn_layer(data, 24, 1, act=\'relu\')\n"
  strings: "  File \"/home/users//tmp/face_detection_faceboxes/pyramidbox.py\", line 221, in _faceboxes\n    conv_inception = inceptionA(conv_inception)\n"
  strings: "  File \"/home/users/tmp/face_detection_faceboxes/pyramidbox.py\", line 167, in __init__\n    self._faceboxes()\n"
  strings: "  File \"faceboxes_eval.py\", line 307, in <module>\n    is_infer=True)\n"
}

NHZlX avatar May 23 '19 03:05 NHZlX

Since you haven't replied for more than a year, we have closed this issue/pr. If the problem is not solved or there is a follow-up one, please reopen it at any time and we will continue to follow up. 由于您超过一年未回复,我们将关闭这个issue/pr。 若问题未解决或有后续问题,请随时重新打开,我们会继续跟进。

paddle-bot-old avatar Jun 08 '20 09:06 paddle-bot-old