Skip to content

Commit bf9ed4a

Browse files
authored
Merge pull request #8499 from yu239/develop
fix a bug of sub() in layer_math.py
2 parents 0e187bc + 59bfa3e commit bf9ed4a

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

python/paddle/trainer_config_helpers/layer_math.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def add(layeroutput, other):
7575

7676
def sub(layeroutput, other):
7777
if is_compatible_with(other, float):
78-
return slope_intercept_layer(input=layeroutput, intercept=other)
78+
return slope_intercept_layer(input=layeroutput, intercept=-other)
7979
if not isinstance(other, LayerOutput):
8080
logger.fatal("LayerOutput can only be subtracted with"
8181
" another Layeroutput or a number")

python/paddle/trainer_config_helpers/tests/configs/protostr/math_ops.protostr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ layers {
230230
input_layer_name: "__mixed_1__"
231231
}
232232
slope: 1.0
233-
intercept: 2
233+
intercept: -2
234234
}
235235
layers {
236236
name: "__slope_intercept_layer_4__"
@@ -411,4 +411,3 @@ sub_models {
411411
output_layer_names: "__mixed_3__"
412412
is_recurrent_layer_group: false
413413
}
414-

0 commit comments

Comments
 (0)