I think (but I am not sure, just trying to understand) the reason is the following: If you look at the code beside (in C):
sum += *target_data > 0 ? *target_data * (log(*target_data) - *input_data) : 0;
If it was *target_data * (log(*target_data) - log(*input_data)) you would have to also make sure that *input_data>0. Then, if it returns 0, you don’t know if the error is coming from target or input.