关于静态图转向动态图的TracedLayer的文档不能实现
Created by: zt991211
我的相关报错源码如下:
if __name__ == '__main__':
# 创建模型
img=[]
img.append(transform_img(np.array(Image.open('/home/aistudio/work/train-images/V0001_0.png'))))
img = np.array(img).astype('float32')
DiscROI_size=600
with fluid.dygraph.guard():
model = M_net()
#启动训练过程
#train(model)
model_state_dict, _ = fluid.load_dygraph('/home/aistudio/work/mnet30.pdparams')
model.load_dict(model_state_dict)
in_var = fluid.dygraph.to_variable(img)
out_dygraph, static_layer = fluid.dygraph.TracedLayer.trace(model, inputs=[in_var])
out_static_graph = static_layer([in_var])
static_layer.save_inference_model(dirname='/home/aistudio/work/mnet_model')
place = fluid.CPUPlace()
exe = fluid.Executor(place)
program, feed_vars, fetch_vars = fluid.io.load_inference_model('/home/aistudio/work/mnet_model',
executor=exe)
fetch, = exe.run(program, feed={feed_vars[0]: in_var},fetch_list=fetch_vars)
print(fetch.shape)
基本是按照文档源码的格式写的,但现在报错了 出现在fluid.io.load_inference_model('/home/aistudio/work/mnet_model', executor=exe)这一行
报错原因如下: 报错在那个exe那里 ValueError:‘type’ to initialized an Operator can not be None。