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

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

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