提交 075fbcbb 编写于 作者: W walloollaw 提交者: qingqing01

caffe2fluid: Fix bug in Scale layer transformation and model saving (#934)

* caffe2fluid: fix bug in transforming Scale layer without bias parameter

* caffe2fluid: fix bug about Scale layer transformation and model saving
上级 1b2641aa
......@@ -47,7 +47,11 @@ mv results.paddle $paddle_results
caffe_results="$results_root/${model_name}.caffe"
rm -rf $caffe_results
rm -rf "results.caffe"
cfpython ./infer.py caffe $model_prototxt $model_caffemodel $paddle_results/data.npy
PYTHON=`which cfpython`
if [[ -z $PYTHON ]];then
PYTHON=`which python`
fi
$PYTHON ./infer.py caffe $model_prototxt $model_caffemodel $paddle_results/data.npy
if [[ $? -ne 0 ]] || [[ ! -e "results.caffe" ]];then
echo "not found caffe's results, maybe failed to do inference with caffe"
exit 1
......@@ -60,5 +64,5 @@ cat $model_prototxt | grep name | perl -ne 'if(/^\s*name:\s+\"([^\"]+)/){ print
#4, compare one by one
for i in $(cat ".layer_names" | tail -n1);do
echo "process $i"
python compare.py $caffe_results/${i}.npy $paddle_results/${i}.npy
$PYTHON compare.py $caffe_results/${i}.npy $paddle_results/${i}.npy
done
......@@ -78,7 +78,7 @@ class MyNet(object):
exe,
main_program=None,
model_filename=model_filename,
params_filename=model_filename)
params_filename=params_filename)
return 0
......
......@@ -318,7 +318,9 @@ class ParameterNamer(object):
if len(node.data) == 4:
names += ('scale', 'offset')
elif node.kind == NodeKind.Scale:
names = ('scale', 'offset')
names = ('scale', )
if getattr(node.parameters, 'bias_term', False):
names = ('scale', 'offset')
else:
warn('Unhandled parameters when naming this it[%s]' %
(node.kind))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册