未验证 提交 c9f10e2b 编写于 作者: S SunAhong1993 提交者: GitHub

Merge pull request #33 from SunAhong1993/master

fix the flatten and detection
......@@ -49,13 +49,13 @@ def detectionoutput_layer(inputs,
pbv = fluid.layers.reshape(x=pbv, shape=[-1, 4])
mbox_loc = inputs[0]
mbox_loc = fluid.layers.reshape(
x=mbox_loc, shape=[-1, mbox_conf_flatten.shape[1], 4])
x=mbox_loc, shape=[0, mbox_conf_flatten.shape[1], 4])
default = {"nms_threshold": 0.3, "top_k": 10, "eta": 1.0}
fields = ['eta', 'top_k', 'nms_threshold']
for f in default.keys():
if not nms_param.has_key(f):
if f not in nms_param:
nms_param[f] = default[f]
nmsed_outs = fluid.layers.detection_output(
......
......@@ -2,7 +2,7 @@
more info can be found here: http://caffe.berkeleyvision.org/tutorial/layers/flatten.html
"""
from .register import register
from functools import reduce
def flatten_shape(input_shape, axis=1, end_axis=-1):
""" calculate the output shape of this layer using input shape
......@@ -29,6 +29,8 @@ def flatten_shape(input_shape, axis=1, end_axis=-1):
% (start_axis, end_axis)
output_shape = input_shape[0:start_axis]
flat_sz = reduce(lambda a, b: a * b, input_shape[start_axis:end_axis])
if flat_sz < 0:
flat_sz = -1
output_shape += [flat_sz]
output_shape += input_shape[end_axis:-1]
......@@ -52,9 +54,8 @@ def flatten_layer(input, name, axis=1, end_axis=-1):
input_shape = list(input.shape)
if input_shape[0] == -1:
input_shape[0] = 1
input_shape[0] = 0
output_shape = flatten_shape(input_shape, axis=axis, end_axis=end_axis)
output_shape[0] = -1
else:
output_shape = flatten_shape(input_shape, axis=axis, end_axis=end_axis)
......
......@@ -79,11 +79,7 @@ def reshape_layer(input, name, shape, axis=0, num_axes=-1):
output (variable): output variable for this layer
"""
fluid = import_fluid()
input_shape = list(input.shape)
print(input_shape)
print(shape)
if input_shape[0] == -1:
input_shape[0] = 0
output_shape = reshape_shape(input_shape, shape, axis, num_axes)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册