diff --git a/paddle/gserver/layers/RotateLayer.cpp b/paddle/gserver/layers/RotateLayer.cpp index 10195193316eae0f545f034c3d3a93f069f327aa..269ad43b3180bdc855b97f20cf7c20d06e99f9c0 100644 --- a/paddle/gserver/layers/RotateLayer.cpp +++ b/paddle/gserver/layers/RotateLayer.cpp @@ -40,19 +40,17 @@ void RotateLayer::forward(PassType passType) { MatrixPtr outV = getOutputValue(); - for (int b = 0; b < batchSize_; b ++) { - MatrixPtr inputSample - = Matrix::create(input->getData() + b * sampleSize_, - sampleHeight_, - sampleWidth_, - false, - useGpu_); - MatrixPtr outputSample - = Matrix::create(outV->getData() + b * sampleSize_, - sampleWidth_, - sampleHeight_, - false, - useGpu_); + for (int b = 0; b < batchSize_; b++) { + MatrixPtr inputSample = Matrix::create(input->getData() + b * sampleSize_, + sampleHeight_, + sampleWidth_, + false, + useGpu_); + MatrixPtr outputSample = Matrix::create(outV->getData() + b * sampleSize_, + sampleWidth_, + sampleHeight_, + false, + useGpu_); inputSample->rotate(outputSample, false, true); } @@ -71,21 +69,21 @@ void RotateLayer::backward(const UpdateCallback& callback) { // the grad should be rotated in the reverse direction MatrixPtr preGrad = getInputGrad(0); - for (int b = 0; b < batchSize_; b ++) { - MatrixPtr inputSampleGrad - = Matrix::create(preGrad->getData() + b * sampleSize_, - sampleHeight_, - sampleWidth_, - false, - useGpu_); - MatrixPtr outputSampleGrad - = Matrix::create(outputGrad->getData() + b * sampleSize_, - sampleWidth_, - sampleHeight_, - false, - useGpu_); - MatrixPtr tmpGrad - = Matrix::create(sampleHeight_, sampleWidth_, false, useGpu_); + for (int b = 0; b < batchSize_; b++) { + MatrixPtr inputSampleGrad = + Matrix::create(preGrad->getData() + b * sampleSize_, + sampleHeight_, + sampleWidth_, + false, + useGpu_); + MatrixPtr outputSampleGrad = + Matrix::create(outputGrad->getData() + b * sampleSize_, + sampleWidth_, + sampleHeight_, + false, + useGpu_); + MatrixPtr tmpGrad = + Matrix::create(sampleHeight_, sampleWidth_, false, useGpu_); outputSampleGrad->rotate(tmpGrad, false, false); inputSampleGrad->add(*tmpGrad); } diff --git a/python/paddle/trainer/config_parser.py b/python/paddle/trainer/config_parser.py index 97744ed32ecbdad78cc7c1de5ff55dc561828a31..62efe5fca0cacae9e4e5258622b9a688a28e831e 100644 --- a/python/paddle/trainer/config_parser.py +++ b/python/paddle/trainer/config_parser.py @@ -1833,7 +1833,6 @@ class PoolLayer(LayerBase): pool_conf.channels) - @config_layer('spp') class SpatialPyramidPoolLayer(LayerBase): def __init__(self, name, inputs, **xargs): diff --git a/python/paddle/trainer_config_helpers/layers.py b/python/paddle/trainer_config_helpers/layers.py index c502885cf9efbd0073076d23a26417153a456ec1..c506977ca4e405c6f2299641bc1ce1bf0c4dcb79 100755 --- a/python/paddle/trainer_config_helpers/layers.py +++ b/python/paddle/trainer_config_helpers/layers.py @@ -1707,15 +1707,17 @@ def rotate_layer(input, height, name=None, layer_attr=None): :rtype: LayerOutput """ assert isinstance(input, LayerOutput) - l = Layer(name=name, - height=height, - type=LayerType.ROTATE_LAYER, - inputs=[input.name], - **ExtraLayerAttribute.to_kwargs(layer_attr)) - return LayerOutput(name=name, - layer_type=LayerType.ROTATE_LAYER, - parents=[input], - size=l.config.size) + l = Layer( + name=name, + height=height, + type=LayerType.ROTATE_LAYER, + inputs=[input.name], + **ExtraLayerAttribute.to_kwargs(layer_attr)) + return LayerOutput( + name=name, + layer_type=LayerType.ROTATE_LAYER, + parents=[input], + size=l.config.size) @wrap_name_default() @@ -1750,11 +1752,12 @@ def flip_layer(input, height, name=None, layer_attr=None): :rtype: LayerOutput """ assert isinstance(input, LayerOutput) - return rotate_layer(input=rotate_layer(input=input, - height=height), - height=height, - name=name, - layer_attr=layer_attr) + return rotate_layer( + input=rotate_layer( + input=input, height=height), + height=height, + name=name, + layer_attr=layer_attr) @wrap_name_default() diff --git a/python/paddle/trainer_config_helpers/tests/layers_test_config.py b/python/paddle/trainer_config_helpers/tests/layers_test_config.py index 10b7358d929b751b0f35daeb1a2661013145236d..3d417a00601d567d4b623ec6dbfdf6944d10a1b3 100644 --- a/python/paddle/trainer_config_helpers/tests/layers_test_config.py +++ b/python/paddle/trainer_config_helpers/tests/layers_test_config.py @@ -39,10 +39,8 @@ z1 = mixed_layer( assert z1.size > 0 y2 = fc_layer(input=y, size=15) -z2 = rotate_layer(input=y2, - height=5) -z3 = flip_layer(input=y2, - height=3) +z2 = rotate_layer(input=y2, height=5) +z3 = flip_layer(input=y2, height=3) cos1 = cos_sim(a=x1, b=y1) cos3 = cos_sim(a=x1, b=y2, size=3)