From ed3e5717ba97dfca2348a6f29a3180b2c591bb3a Mon Sep 17 00:00:00 2001 From: Kexin Zhao Date: Wed, 17 Jan 2018 16:56:19 -0800 Subject: [PATCH] fix bug --- paddle/inference/inference.cc | 2 +- python/paddle/v2/fluid/io.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/paddle/inference/inference.cc b/paddle/inference/inference.cc index 1f6e510b8..4a8bc21b1 100644 --- a/paddle/inference/inference.cc +++ b/paddle/inference/inference.cc @@ -89,7 +89,7 @@ void InferenceEngine::LoadInferenceModel( } bool InferenceEngine::IsParameter(const framework::VarDesc* var) { - if (var->Persistable()) { + if (var->Persistable() && var->Name() != "feed" && var->Name() != "fetch") { // There are many unreachable variables in the program for (size_t i = 0; i < program_->Size(); ++i) { const framework::BlockDesc& block = program_->Block(i); diff --git a/python/paddle/v2/fluid/io.py b/python/paddle/v2/fluid/io.py index 516b8471d..ad4837c3f 100644 --- a/python/paddle/v2/fluid/io.py +++ b/python/paddle/v2/fluid/io.py @@ -15,6 +15,7 @@ import os import cPickle as pickle from paddle.v2.fluid.framework import Program, Parameter, default_main_program, Variable +from . import core __all__ = [ 'save_vars', @@ -244,10 +245,10 @@ def save_inference_model(dirname, # Save only programDesc of inference_program in binary format # in another file: __model__.dat global_block = inference_program.global_block() - feed_var = global_blok.create_var( + feed_var = global_block.create_var( name='feed', type=core.VarDesc.VarType.FEED_MINIBATCH, persistable=True) - for i, name in enumerated(feeded_var_names): + for i, name in enumerate(feeded_var_names): out = global_block.var(name) global_block.prepend_op( type='feed', @@ -258,10 +259,10 @@ def save_inference_model(dirname, fetch_var = global_block.create_var( name='fetch', type=core.VarDesc.VarType.FETCH_LIST, persistable=True) - for i, name in enumerated(fetch_var_names): + for i, name in enumerate(fetch_var_names): global_block.append_op( type='fetch', - inputs={'X': [var]}, + inputs={'X': [name]}, outputs={'Out': [fetch_var]}, attrs={'col': i}) -- GitLab