提交 efce5514 编写于 作者: S SunAhong1993

add caffe emitter v1

上级 2f9e2ca9
...@@ -164,7 +164,7 @@ class CaffeEmitter(Emitter): ...@@ -164,7 +164,7 @@ class CaffeEmitter(Emitter):
node.layer_type, params) node.layer_type, params)
assert len(node.inputs assert len(node.inputs
) == 1, 'The count of Convolution node\'s input is not 1.' ) == 1, 'The count of Convolution node\'s input is not 1.'
input = self.graph.get_bottom_node(node, idx=0) input = self.graph.get_bottom_node(node, idx=0, copy=True)
attr = { attr = {
'filter_size': kernel, 'filter_size': kernel,
'num_filters': channel, 'num_filters': channel,
...@@ -192,7 +192,7 @@ class CaffeEmitter(Emitter): ...@@ -192,7 +192,7 @@ class CaffeEmitter(Emitter):
node.layer_type, params) node.layer_type, params)
assert len(node.inputs assert len(node.inputs
) == 1, 'The count of Deconvolution node\'s input is not 1.' ) == 1, 'The count of Deconvolution node\'s input is not 1.'
input = self.graph.get_bottom_node(node, idx=0) input = self.graph.get_bottom_node(node, idx=0, copy=True)
attr = { attr = {
'output_size': None, 'output_size': None,
'filter_size': kernel, 'filter_size': kernel,
...@@ -220,7 +220,7 @@ class CaffeEmitter(Emitter): ...@@ -220,7 +220,7 @@ class CaffeEmitter(Emitter):
pool_type = 'avg' pool_type = 'avg'
assert len( assert len(
node.inputs) == 1, 'The count of Pooling node\'s input is not 1.' node.inputs) == 1, 'The count of Pooling node\'s input is not 1.'
input = self.graph.get_bottom_node(node, idx=0) input = self.graph.get_bottom_node(node, idx=0, copy=True)
attr = { attr = {
'pool_size': kernel, 'pool_size': kernel,
'pool_stride': stride, 'pool_stride': stride,
...@@ -238,7 +238,7 @@ class CaffeEmitter(Emitter): ...@@ -238,7 +238,7 @@ class CaffeEmitter(Emitter):
def ReLU(self, node): def ReLU(self, node):
assert len( assert len(
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) input = self.graph.get_bottom_node(node, idx=0, copy=True)
attr = {'name': string(node.layer_name)} attr = {'name': string(node.layer_name)}
node.fluid_code.add_layer("relu", node.fluid_code.add_layer("relu",
inputs=input, inputs=input,
...@@ -255,7 +255,7 @@ class CaffeEmitter(Emitter): ...@@ -255,7 +255,7 @@ class CaffeEmitter(Emitter):
# just scales by alpha (as does Krizhevsky's paper). # just scales by alpha (as does Krizhevsky's paper).
# We'll account for that here. # We'll account for that here.
alpha = params.alpha / float(params.local_size) alpha = params.alpha / float(params.local_size)
input = self.graph.get_bottom_node(node, idx=0) input = self.graph.get_bottom_node(node, idx=0, copy=True)
attr = { attr = {
'n': params.local_size, 'n': params.local_size,
'k': 1.0, 'k': 1.0,
...@@ -288,7 +288,7 @@ class CaffeEmitter(Emitter): ...@@ -288,7 +288,7 @@ class CaffeEmitter(Emitter):
params = node.layer.inner_product_param params = node.layer.inner_product_param
assert params.axis == 1 assert params.axis == 1
assert params.bias_term == True assert params.bias_term == True
input = self.graph.get_bottom_node(node, idx=0) input = self.graph.get_bottom_node(node, idx=0, copy=True)
attr = { attr = {
'size': params.num_output, 'size': params.num_output,
'name': string(node.layer_name), 'name': string(node.layer_name),
...@@ -304,7 +304,7 @@ class CaffeEmitter(Emitter): ...@@ -304,7 +304,7 @@ class CaffeEmitter(Emitter):
def Softmax(self, node): def Softmax(self, node):
assert len( assert len(
node.inputs) == 1, 'The count of Softmax node\'s input is not 1.' node.inputs) == 1, 'The count of Softmax node\'s input is not 1.'
input = self.graph.get_bottom_node(node, idx=0) input = self.graph.get_bottom_node(node, idx=0, copy=True)
params = node.layer.softmax_param params = node.layer.softmax_param
axis = params.axis axis = params.axis
shape = node.input_shape[0] shape = node.input_shape[0]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册