提交 1271bd02 编写于 作者: driftcloudy's avatar driftcloudy

caffe2paddle, support relu6/upsample,compatible with LeakyReLU,repair axpy and dropout

上级 d142d861
......@@ -93,10 +93,13 @@ class CaffeGraph(Graph):
drop_layer_bottom = layer.bottom[0]
if drop_layer_top != drop_layer_bottom:
for next_layer in layers:
for next_layer_bottom_idx, next_layer_bottom in enumerate(next_layer.bottom):
for next_layer_bottom_idx, next_layer_bottom in enumerate(
next_layer.bottom):
if drop_layer_top == next_layer_bottom:
next_layer.bottom.remove(drop_layer_top)
next_layer.bottom.insert(next_layer_bottom_idx, drop_layer_bottom)
next_layer.bottom.insert(
next_layer_bottom_idx,
drop_layer_bottom)
if not exclude:
filtered_layers.append(layer)
......
......@@ -18,7 +18,4 @@ def relu6_weights(name, data=None):
register(
kind='ReLU6',
shape=relu6_shape,
layer=relu6_layer,
weights=relu6_weights)
kind='ReLU6', shape=relu6_shape, layer=relu6_layer, weights=relu6_weights)
......@@ -42,10 +42,8 @@ def upsample_layer(inputs, scale, input_shape=None, name=None):
:return:
"""
x = inputs[0]
out = fluid.layers.resize_nearest(x,
align_corners=False,
scale=scale,
name=name)
out = fluid.layers.resize_nearest(
x, align_corners=False, scale=scale, name=name)
return out
......@@ -61,4 +59,8 @@ def upsample_weights(name, data=None):
return weights_name
register(kind='Upsample', shape=upsample_shape, layer=upsample_layer, weights=upsample_weights)
register(
kind='Upsample',
shape=upsample_shape,
layer=upsample_layer,
weights=upsample_weights)
......@@ -448,14 +448,11 @@ class CaffeOpMapper(OpMapper):
if params.HasField('negative_slope') and params.negative_slope != 0:
negative_slope = float(params.negative_slope)
attr = {
'alpha': negative_slope
}
attr = {'alpha': negative_slope}
node.fluid_code.add_layer(
'leaky_relu', inputs=input, output=node, param_attr=attr)
else:
node.fluid_code.add_layer(
'relu', inputs=input, output=node)
node.fluid_code.add_layer('relu', inputs=input, output=node)
def PReLU(self, node):
assert len(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册