diff --git a/python/paddle/trainer_config_helpers/layer_math.py b/python/paddle/trainer_config_helpers/layer_math.py index e1c8f0c3500413b364546bc3352cf3a64d3581de..ee84188baccc8c246b7a791c77556b403698f2d9 100644 --- a/python/paddle/trainer_config_helpers/layer_math.py +++ b/python/paddle/trainer_config_helpers/layer_math.py @@ -75,7 +75,7 @@ LayerOutput.__add__ = add def sub(layeroutput, other): if is_compatible_with(other, float): - return slope_intercept_layer(input=layeroutput, intercept=other) + return slope_intercept_layer(input=layeroutput, intercept=-other) if not isinstance(other, LayerOutput): logger.fatal("LayerOutput can only be subtracted with" " another Layeroutput or a number") diff --git a/python/paddle/trainer_config_helpers/tests/configs/protostr/math_ops.protostr b/python/paddle/trainer_config_helpers/tests/configs/protostr/math_ops.protostr index eaaf7fd6f5b4cec1a2f95622831cf95436a1514a..582207741ab76370d9c5c09598c3f7a81f013b73 100644 --- a/python/paddle/trainer_config_helpers/tests/configs/protostr/math_ops.protostr +++ b/python/paddle/trainer_config_helpers/tests/configs/protostr/math_ops.protostr @@ -230,7 +230,7 @@ layers { input_layer_name: "__mixed_1__" } slope: 1.0 - intercept: 2 + intercept: -2 } layers { name: "__slope_intercept_layer_4__" @@ -411,4 +411,3 @@ sub_models { output_layer_names: "__mixed_3__" is_recurrent_layer_group: false } -