3
$\begingroup$

If we use ReLU activations, then the function which our neural network represents is piecewise linear. It is not smooth and the first derivative doesn't exist everywhere.

However, if we use sigmoid or tanh activations, then the function represented by the neural network is smooth. The first derivative exists everywhere and is continuous.

I am interested to know whether we can say anything about the second derivative of a neural network with sigmoid/tanh activations. Are there any guarantees we can make about whether or not it exists everywhere? Or is this something which doesn't have a simple answer?

$\endgroup$

1 Answer 1

3
$\begingroup$

If we are talking about the usual fully connected / convolution layers combined with activations (i.e. not a complicated deep learning model with all sorts of layers), yes, they are second-order differentiable given that the activations are second-order differentiable. Or, even, we can say that, the overall function is n-th order differentiable if activations are; because the rest of the operations are just matrix multiplication.

If you think about the partial derivative wrt some variable in the network, it's just scalar multiplication, addition, activation; then the same thing again. For a two layer, it looks like

$$g(x)=f(a_2f(a_1x+b_1)+b_2)$$

which can be easily differentiated as long as $f$ is differentiable.

$\endgroup$
2
  • $\begingroup$ Thank you for the reply, I see. The reason for my question is that I read in a lecture handout that we should ideally avoid differentiating the output of a neural network twice. But if there's no issues with differentiability -- if we use tanh or sigmoid for instance -- I'm not really sure why we shouldn't. Would you happen to have any insights? $\endgroup$ Commented Feb 27 at 15:05
  • $\begingroup$ Not sure, looks like a over-generalization. $\endgroup$
    – gunes
    Commented Feb 27 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.