未验证 提交 8ec74138 编写于 作者: J Jason 提交者: GitHub

Merge pull request #240 from sonixixi/fix-caffe-crop-bug

fix caffe crop opmap
...@@ -797,21 +797,21 @@ class CaffeOpMapper(OpMapper): ...@@ -797,21 +797,21 @@ class CaffeOpMapper(OpMapper):
input = self.graph.get_bottom_node(node, idx=0, copy=True) input = self.graph.get_bottom_node(node, idx=0, copy=True)
example = self.graph.get_bottom_node(node, idx=1, copy=True) example = self.graph.get_bottom_node(node, idx=1, copy=True)
params = node.layer.crop_param params = node.layer.crop_param
axis = parmas.axis axis = params.axis
input_shape = node.input_shape[0] input_shape = node.input_shape[0]
if axis < 0: if axis < 0:
axis += len(input_shape) axis += len(input_shape)
offset_real = [0] * len(input_shape) offset_real = [0] * len(input_shape)
if hasattr(params, offset): if hasattr(params, "offset") and len(params.offset) > 0:
offset = list(params.offset) offset = list(params.offset)
assert (len(input_shape) - axis) == len( assert (len(input_shape) - axis) == len(
offset), "invalid offset[%s] in crop layer" % (str(offset)) offset), "invalid offset[%s] in crop layer" % (str(offset))
offset_real = [0] * axis + offset offset_real = [0] * axis + offset
attr = {'offsets': offset_real, 'name': string(node.layer_name)} attr = {'offsets': list(offset_real), 'name': string(node.layer_name)}
node.fluid_code.add_layer("crop", node.fluid_code.add_layer("crop",
inputs={ inputs={
'x': input, 'x': input,
'y': example 'shape': node.input_shape[1]
}, },
output=node, output=node,
param_attr=attr) param_attr=attr)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册