|
|
|
|
|
by memexy
2198 days ago
|
|
Differentiating through control flow has never made sense to me. What does it mean to differentiate the following function: "f(x) = x > 0 ? x : -x"? If you plot this function you get a sharp corner at 0 which means it's not differentiable there because the limit from the left is -1 and the limit from the right is 1. Since 1 =/= -1 the derivative does not exist at 0. So how are AD libraries claiming to differentiate such functions? Is there an implicit assumption that the user knows the derivative does not make sense at 0? Edit: I just tried this and it gives the wrong answer without any hint that it's incorrect: """ julia> f f (generic function with 1 method) julia> f(0), f'(0) (0, -1) julia> f'(1), f'(-1) (1, -1) """ |
|