# Why binary crossentropy can be used as the loss function in autoencoders?

I was wondering why binary crossentropy can be used as the loss function in autoencoders trained on (normalized) images, e.g. here or this paper? I know that binary crossentropy can be used in binray classification problems where the ground-truth labels (i.e. $$y$$) are either 0 or 1 and therefore when predictions (i.e. $$p$$) are correct, in both cases, the loss value would be zero:

$$BCE(y,p) = -y.log(p) - (1-y).\log{(1-p)}$$

$$BCE(0,0) = 0, BCE(1,1) = 0$$

However, binary crossentropy does not have a value of zero when neither of its arguments are both zero or one, which is the case for an autoencoder with ground-truth labels in range $$[0,1]$$ (i.e. assuming the input data has been normalized in this range). I thought a regression loss function such as mean squared error or mean absolute error must be used instead, which have a value of zero when labels and predictions are the same. What am I missing here?

Now let's verify this is the case for binary crossentropy: we need to show that when we reach the minimum point of binary crossentropy it implies that $$y = p$$, i.e. predictions equal to true labels. To find the minimum point, we take the derivative with respect to $$p$$ and set it equal to zero (note that in the following calculations I have assumed that the $$log$$ is natural logarithm function to make calculations a little easier):
\begin{align}&\frac{\partial BCE(y,p)}{\partial p} = 0\\ &\implies -y.\dfrac{1}{p} - (1-y).\dfrac{-1}{1-p} = 0\\ &\implies -y.(1-p) + (1-y).p = 0\\ &\implies -y + y.p + p - y.p = 0\\ &\implies p - y = 0\\ &\implies y = p \end{align}