diff --git a/caffe2fluid/kaffe/custom_layers/detection_out.py b/caffe2fluid/kaffe/custom_layers/detection_out.py index ff79e2649efd37cc40f2905f6d97b6fb8103676c..54e0f68bc14ccba3d7b925aa93d3a851cf5e0661 100644 --- a/caffe2fluid/kaffe/custom_layers/detection_out.py +++ b/caffe2fluid/kaffe/custom_layers/detection_out.py @@ -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( diff --git a/caffe2fluid/kaffe/custom_layers/flatten.py b/caffe2fluid/kaffe/custom_layers/flatten.py index ebb97718e3294bb473752bc6235917bed0db0650..271cc99f790976ed463dfcfdae5527b052a9cc97 100644 --- a/caffe2fluid/kaffe/custom_layers/flatten.py +++ b/caffe2fluid/kaffe/custom_layers/flatten.py @@ -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) diff --git a/caffe2fluid/kaffe/custom_layers/reshape.py b/caffe2fluid/kaffe/custom_layers/reshape.py index b4ec051d7b4f349079f81de874aef9cdf2d18a65..fc2da276683fc70bc83f85199aaf94d794009082 100644 --- a/caffe2fluid/kaffe/custom_layers/reshape.py +++ b/caffe2fluid/kaffe/custom_layers/reshape.py @@ -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)