I would like to find the derivative of the discrete max operator in numpy. For example, given a=np.array([1,2,3,2,1]), calling np.max(a) gives 3. Can this operation be differentiated? From thinking about what the derivative means, it seems that given a small change in a, the derivative of max(a) should be 0 unless the small change causes max(a) to change to a new value, in which case the derivative could be very large indeed. Does this line of thinking make sense at all?
Many thanks!
Asked
Active
Viewed 80 times
0
Mr Squid
- 193
-
$\max(x)$ is not differentiable, but if you tell us more about what you are trying to achieve, we might be able to help. – Amit Hochman Mar 18 '20 at 05:23
-
Are you differentiating with respect to the array components? The partial derivatives exist almost everywhere, equal to $0$ or $\pm 1$. – epimorphic Mar 19 '20 at 03:37