From 73dcf2cd58b9e38b465853dd95ace9e16f84f164 Mon Sep 17 00:00:00 2001 From: Haonan Date: Fri, 3 Feb 2017 11:49:38 -0800 Subject: [PATCH] improving code comments --- paddle/gserver/layers/RotateLayer.cpp | 3 ++- paddle/gserver/layers/RotateLayer.h | 2 +- paddle/gserver/tests/test_LayerGrad.cpp | 3 ++- python/paddle/trainer_config_helpers/layers.py | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/paddle/gserver/layers/RotateLayer.cpp b/paddle/gserver/layers/RotateLayer.cpp index d928f1d93d..7c71088d78 100644 --- a/paddle/gserver/layers/RotateLayer.cpp +++ b/paddle/gserver/layers/RotateLayer.cpp @@ -38,7 +38,8 @@ void RotateLayer::forward(PassType passType) { size_ = input->getWidth(); CHECK_GE(size_, height_ * width_); CHECK_EQ(size_ % (height_ * width_), 0) - << "The input's depth should be an int"; + << "total size_ is not dividable by (height_ * width_), i.e., " + << "channel number should be an integer"; channels_ = size_ / (height_ * width_); resizeOutput(batchSize_, size_); diff --git a/paddle/gserver/layers/RotateLayer.h b/paddle/gserver/layers/RotateLayer.h index a6f565a7e5..1a64d4d5a5 100644 --- a/paddle/gserver/layers/RotateLayer.h +++ b/paddle/gserver/layers/RotateLayer.h @@ -21,7 +21,7 @@ namespace paddle { /** * A layer for rotating a multi-channel feature map (M x N x C) in the spatial * domain - * The rotation is 90 degrees in clock-wise + * The rotation is 90 degrees in clock-wise for each channel * \f[ * y(j,i,:) = x(M-i-1,j,:) * \f] diff --git a/paddle/gserver/tests/test_LayerGrad.cpp b/paddle/gserver/tests/test_LayerGrad.cpp index 685d2ca542..7e6842742e 100644 --- a/paddle/gserver/tests/test_LayerGrad.cpp +++ b/paddle/gserver/tests/test_LayerGrad.cpp @@ -1320,9 +1320,10 @@ TEST(Layer, RotateLayer) { TestConfig config; config.biasSize = 0; config.layerConfig.set_type("rotate"); - const int INPUT_SIZE = 64; // height * width * depth + const int CHANNEL = 2; const int HEIGHT = 8; const int WIDTH = 4; + const int INPUT_SIZE = HEIGHT * WIDTH * CHANNEL; config.layerConfig.set_size(INPUT_SIZE); config.layerConfig.set_height(HEIGHT); config.layerConfig.set_width(WIDTH); diff --git a/python/paddle/trainer_config_helpers/layers.py b/python/paddle/trainer_config_helpers/layers.py index 2636f6cc1a..66b842a25d 100755 --- a/python/paddle/trainer_config_helpers/layers.py +++ b/python/paddle/trainer_config_helpers/layers.py @@ -1679,8 +1679,8 @@ def trans_layer(input, name=None, layer_attr=None): @layer_support() def rotate_layer(input, height, width, name=None, layer_attr=None): """ - A layer for rotating 90 degrees (clock-wise), usually used when the input sample - is some image or feature map. + A layer for rotating 90 degrees (clock-wise) for each feature channel, + usually used when the input sample is some image or feature map. .. math:: y(j,i,:) = x(M-i-1,j,:) -- GitLab