Cross Validation Error for multiclass classification

How can I calculate error J_cv for multiclass classification, say handwritten digit recognition of digits 0 to 9 as log(1-yhat) becomes undefined if 1-yhat is negative?

The loss function you mentioned does not seem correct to me for multi-class.

The y labels will be one-hot encoded, so the values are only 0 or 1, and the y_hat values will be between 0 and 1.