提交 4fe0b4d2 编写于 作者: S sunyanfang01

compatible with python2 and python3

上级 32375eeb
......@@ -42,7 +42,6 @@ def convert(def_path, caffemodel_path, data_output_path, code_output_path,
if code_output_path:
print_stderr('Saving source...')
with open(code_output_path, 'wb') as src_out:
# print(type(transformer.transform_source()))
src_out.write(str.encode(transformer.transform_source()))
print_stderr('set env variable before using converted model '\
'if used custom_layers:')
......
......@@ -55,7 +55,7 @@ def compare(path1, path2, no_exception):
print('[max_df:%.4e, sq_df:%.4e] when compare %s <=> %s' %
(max_df, sq_df, os.path.basename(f1), os.path.basename(f2)))
if no_exception is False:
assert (max_df < 1e-4), \
assert (max_df < 1e-5), \
'max_df is too large with value[%.6e]' % (max_df)
assert (sq_df < 1e-10), \
'sq_df is too large with value[%.6e]' % (sq_df)
......
......@@ -22,7 +22,7 @@ def crop_shape(input_shape, shape=None):
input_shape.shape), "input_shape is diff with output_shape"
return shape
else:
raise Exception, "crop_shape input error"
raise Exception("crop_shape input error")
return None
......@@ -54,7 +54,7 @@ def crop_layer(input, name, shape=None, axis=2, offset=None):
output_shape = shape
input_tensor = input
else:
raise Exception, "crop_layer input error"
raise Exception("crop_layer input error")
assert len(output_shape) == len(
input_shape), "input_shape is diff with output_shape"
......
......@@ -2,7 +2,6 @@ import re
import numbers
from collections import namedtuple
import sys
sys.path.append('~/paddlepaddle/X2Paddle_v2.0/caffe2fluid/kaffe/custom_layers')
from . import custom_layers
from .shapes import *
......
......@@ -42,7 +42,7 @@ class MyNet(object):
def convert(cls, npy_model, fluid_path, outputs=None):
fluid = import_fluid()
shapes = cls.input_shapes()
input_name = list(shapes.keys())[0] #need to review
input_name = list(shapes.keys())[0]
feed_data = {}
for name, shape in shapes.items():
data_layer = fluid.layers.data(
......
......@@ -110,7 +110,7 @@ class Network(object):
continue
layer = self.layers[op_name]
for param_name, data in data_dict[op_name].items(): #need to review
for param_name, data in data_dict[op_name].items():
try:
name = '%s_%s' % (op_name, param_name)
v = fluid.global_scope().find_var(name)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册