提交 83abbce8 编写于 作者: G guosheng

Follow comments and refine ScaleShiftLayer

上级 7d2ef02a
......@@ -17,8 +17,9 @@ limitations under the License. */
namespace paddle {
/**
* A layer does scaling and shifting to the input by appling a slope and
* an intercept which are trainable to the input element-wise.
* A layer applies a slope and an intercept to the input element-wise for
* scaling and shifting. Noting that this layer is trainable which differs
* from the SlopeInterceptLayer.
*
* \f[
* y = wx + b
......
......@@ -2008,8 +2008,8 @@ TEST(Layer, RowL2NormLayer) {
}
TEST(Layer, ScaleShiftLayer) {
const size_t batchSize = 128;
const size_t size = 512;
const size_t batchSize = 16;
const size_t size = 32;
TestConfig config;
config.layerConfig.set_type("scale_shift");
config.layerConfig.set_size(size);
......
......@@ -6219,8 +6219,9 @@ def kmax_sequence_score_layer(input, name=None, beam_size=1):
@wrap_bias_attr_default()
def scale_shift_layer(input, name=None, param_attr=None, bias_attr=None):
"""
A layer does scaling and shifting to the input by appling a slope and
an intercept which are trainable to the input element-wise.
A layer applies a slope and an intercept to the input element-wise for
scaling and shifting. Noting that this layer is trainable which differs
from the slope_intercept_layer.
.. math::
y = w * x + b
......
......@@ -14,7 +14,6 @@ layers {
input_layer_name: "data"
input_parameter_name: "___scale_shift_0__.w0"
}
bias_parameter_name: "___scale_shift_0__.wbias"
}
layers {
name: "__scale_shift_1__"
......@@ -25,6 +24,7 @@ layers {
input_layer_name: "data"
input_parameter_name: "___scale_shift_1__.w0"
}
bias_parameter_name: "___scale_shift_1__.wbias"
}
parameters {
name: "___scale_shift_0__.w0"
......@@ -37,24 +37,24 @@ parameters {
initial_smart: true
}
parameters {
name: "___scale_shift_0__.wbias"
name: "___scale_shift_1__.w0"
size: 1
initial_mean: 0.0
initial_std: 0.0
initial_std: 1.0
dims: 1
dims: 1
initial_strategy: 0
initial_smart: false
initial_smart: true
}
parameters {
name: "___scale_shift_1__.w0"
name: "___scale_shift_1__.wbias"
size: 1
initial_mean: 0.0
initial_std: 1.0
initial_std: 0.0
dims: 1
dims: 1
initial_strategy: 0
initial_smart: true
initial_smart: false
}
input_layer_names: "data"
output_layer_names: "__scale_shift_0__"
......
from paddle.trainer_config_helpers import *
settings(batch_size=1000, learning_rate=1e-5)
data = data_layer(name='data', size=100)
scale = scale_shift_layer(input=data)
scale = scale_shift_layer(input=data, bias_attr=False)
scale_shift = scale_shift_layer(input=data, bias_attr=False)
scale_shift = scale_shift_layer(input=data)
outputs(scale, scale_shift)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册