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

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

上级 ae698482
...@@ -88,39 +88,6 @@ class CaffeGraph(Graph): ...@@ -88,39 +88,6 @@ class CaffeGraph(Graph):
# filter them out here. # filter them out here.
if (not exclude) and (phase == 'test'): if (not exclude) and (phase == 'test'):
exclude = (type_str == 'Dropout') exclude = (type_str == 'Dropout')
'''
如果要去除Dropout Layer的话,原先这里写的不对,因为还得修正下一层Layer的bottom指向
例如:
layer {
name: "pool_8x8_s1"
type: "Pooling"
bottom: "inception_c2_concat"
top: "pool_8x8_s1"
pooling_param {
pool: AVE
global_pooling: true
}
}
layer {
name: "pool_8x8_s1_drop"
type: "Dropout"
bottom: "pool_8x8_s1"
top: "pool_8x8_s1_drop"
dropout_param {
dropout_ratio: 0.2
}
}
layer {
name: "classifier"
type: "InnerProduct"
bottom: "pool_8x8_s1_drop"
}
这种prototxt形式下,直接去除pool_8x8_s1_drop不行
会导致dropout的下一层找不到正确的bottom而报错
需要将下一层里的bottom指向dropout的上一层
'''
if layer.type == 'Dropout': if layer.type == 'Dropout':
drop_layer_top = layer.top[0] drop_layer_top = layer.top[0]
drop_layer_bottom = layer.bottom[0] drop_layer_bottom = layer.bottom[0]
......
...@@ -444,7 +444,6 @@ class CaffeOpMapper(OpMapper): ...@@ -444,7 +444,6 @@ class CaffeOpMapper(OpMapper):
node.inputs) == 1, 'The count of ReLU node\'s input is not 1.' node.inputs) == 1, 'The count of ReLU node\'s input is not 1.'
input = self.graph.get_bottom_node(node, idx=0, copy=True) input = self.graph.get_bottom_node(node, idx=0, copy=True)
# 如果存在negative_slope,则相当于 LeakyReLU
params = node.layer.relu_param params = node.layer.relu_param
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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册