Log-cosh loss calculator
Compute mean log-cosh loss for four signed residuals, with stable evaluation for large residual magnitudes.
inputs.
How to use this calculator
Compute mean log-cosh loss for four signed residuals, with stable evaluation for large residual magnitudes.
- Enter Residual 1, Residual 2, Residual 3, Residual 4. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
How the Log-cosh loss calculator works
Compute mean log-cosh loss for four signed residuals, with stable evaluation for large residual magnitudes.
Inputs and units
- Residual 1: First observed-minus-predicted residual, in the chosen common scale.
- Residual 2: Second signed residual; negative values are valid.
- Residual 3: Third signed residual, with the same scaling as the others.
- Residual 4: Fourth signed residual; all four contribute equally.
Formula and method
loss = Σ ln(cosh(eᵢ)) / 4; for large |e| use |e| + ln(1 + exp(−2|e|)) − ln(2)
Worked example
Residuals 1.2, −0.8, 2, and 1 give log-cosh terms about 0.593689, 0.290754, 1.325003, and 0.433781; their mean is 0.660807.
Interpreting the result
Near zero, each term behaves like half the squared residual; for large magnitudes its growth is approximately linear. Reversing a residual sign does not change its contribution.
Assumptions and limits
The residual scale matters: use consistently scaled or normalized errors when comparing models. This is a four-observation mean, not a sum or an optimizer.
Sources and method
- Defines mean log-cosh loss; stable equivalent evaluation is independently checked here. TensorFlow: log-cosh loss
Frequently asked questions
Why allow a negative residual?
Log-cosh is an even function: ln(cosh(−e)) = ln(cosh(e)). Direction does not change this loss.
Why not calculate cosh directly for every input?
Direct cosh can overflow for a finite residual such as 1,000. The equivalent log-domain expression retains a finite loss.
How do I use the Log-cosh loss calculator?
Enter Residual 1, Residual 2, Residual 3, Residual 4. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of Log-cosh loss?
Residuals 1.2, −0.8, 2, and 1 give log-cosh terms about 0.593689, 0.290754, 1.325003, and 0.433781; their mean is 0.660807.
What does the Log-cosh loss calculator calculate?
Compute mean log-cosh loss for four signed residuals, with stable evaluation for large residual magnitudes.
See the calculation methodology.