Understanding loss function

Hi sir, can you help me. Until now, I just use the function of framework about loss function. But i not understand the function “log” in equation. Why we need “log” from equation of loss function ?

Hi,

Please be specific, which loss function are you talking about? What equation ? What are you training ? Nothing is obvious without context.

My guess is that you are working on a classification task. So when you run your model in forward pass for one input data sample, your model will output a prediction for each class. For each output, the prediction represent the probability that your data sample belong to the class (in [0, 1]). But in the other hand, the ground-true target value will be in {0, 1} for each class (1 if it belongs to the class, 0 if not). In this context, it make sense to measure the loss of network on a log scale, as Wikipedia explains:

Since the probabilities of independent events multiply, and logarithms convert multiplication to addition, log probabilities of independent events add. Log probabilities are thus practical for computations, and have an intuitive interpretation in terms of information theory: the negative of the average log probability is the information entropy of an event. Similarly, likelihoods are often transformed to the log scale, and the corresponding log-likelihood can be interpreted as the degree to which an event supports a statistical model.

Hope it help,
Thomas