There is python code about Relu backward propagation. and code is like dx=(x>0)*dout
, what does x>0
part do? Can anyone explain me this line of code?
Asked
Active
Viewed 145 times
1

arajshree
- 626
- 4
- 13

user3033705
- 11
- 1
-
3Did you try it in isolation? What did you find out? – jonrsharpe Jun 24 '19 at 21:48
-
Please provide a [mcve]. – Code-Apprentice Jun 24 '19 at 21:48
-
You might compare, say, `(True*3)` and `(False*3)`. That said, since `__gt__()` can return objects of *any* type, in isolation, this question isn't amenable to a canonical answer at all. – Charles Duffy Jun 24 '19 at 21:55
-
Since Python operators can be overloaded, it's impossible to know for certain what the `>` will do without knowing the type of `x`. However, for most sensible implementations, the result of `(x>0)` will be either `True` or `False`, and in a numeric context `True` has a value of one and `False` has a value of zero. – Daniel Pryden Jun 24 '19 at 21:55
1 Answers
1
The Relu function is defined as: f(x) = max(0,x)
It means if x<=0
then f(x)=0
, else f(x)=x
.
So if x<=0
, dx=0
, else dx=dout
.

Anubhav Singh
- 8,321
- 4
- 25
- 43