提交 3b8d760d 编写于 作者: D dengkaipeng

fix upsample

上级 02953d8d
...@@ -183,13 +183,13 @@ class YOLOv3Head(object): ...@@ -183,13 +183,13 @@ class YOLOv3Head(object):
return route, tip return route, tip
def _upsample(self, input, scale=2, upsample='nearest', name=None): def _upsample(self, input, scale=2, upsample='nearest', name=None):
upsample = upsample.copy()
if upsample == 'nearest': if upsample == 'nearest':
out = fluid.layers.resize_nearest( out = fluid.layers.resize_nearest(
input=input, scale=float(scale), name=name) input=input, scale=float(scale), name=name)
else: else:
assert isinstance( assert isinstance(
upsample, dict), "Unknown upsample method: {}".format(upsample) upsample, dict), "Unknown upsample method: {}".format(upsample)
upsample = upsample.copy()
assert upsample['type'] in [ assert upsample['type'] in [
'carafe' 'carafe'
], 'Unknown upsample type {}'.format(upsample['type']) ], 'Unknown upsample type {}'.format(upsample['type'])
......
...@@ -75,7 +75,6 @@ def _conv_bn(input, ch_out, filter_size, stride, padding, act=None, name=None): ...@@ -75,7 +75,6 @@ def _conv_bn(input, ch_out, filter_size, stride, padding, act=None, name=None):
filter_size=filter_size, filter_size=filter_size,
stride=stride, stride=stride,
padding=padding, padding=padding,
act=None,
param_attr=ParamAttr(name=name + ".conv.weights"), param_attr=ParamAttr(name=name + ".conv.weights"),
bias_attr=False) bias_attr=False)
...@@ -1588,6 +1587,8 @@ class CARAFEUpsample(object): ...@@ -1588,6 +1587,8 @@ class CARAFEUpsample(object):
w = input_shape[3] w = input_shape[3]
out = fluid.layers.reshape( out = fluid.layers.reshape(
out, [b, int(input.shape[1]), -1, h * self.scale, w * self.scale]) out, [b, int(input.shape[1]), -1, h * self.scale, w * self.scale])
weight = fluid.layers.expand_as(weight, out)
out = fluid.layers.reduce_sum(weight * out, dim=2) out = fluid.layers.reduce_sum(weight * out, dim=2)
return out return out
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册