validation and profiles

This commit is contained in:
Miha Kralj
2026-02-26 22:02:52 -08:00
parent 9ab37c1200
commit 8a1ba95173
317 changed files with 18704 additions and 622 deletions
+27 -1
View File
@@ -1,4 +1,4 @@
# Log-Cosh: Logarithm of Hyperbolic Cosine Loss
# Log-Cosh: Logarithm of Hyperbolic Cosine Loss
> "The smooth operator that acts like L2 for small errors and L1 for large ones."
@@ -89,6 +89,32 @@ LogCosh.Batch(actualSpan, predictedSpan, outputSpan, period: 20);
## Performance Profile
### Operation Count (Streaming Mode)
LogCosh: L = log(cosh(e)) = log((exp(e)+exp(-e))/2). Numerically stabilized as |e| + log(1+exp(-2|e|)) - log(2).
| Operation | Count | Cost (cycles) | Subtotal |
| :--- | :---: | :---: | :---: |
| Residual e = actual - forecast | 1 | ~2 cy | ~2 cy |
| Absolute value + two exp() calls | 2 | ~15 cy | ~30 cy |
| log() call | 1 | ~15 cy | ~15 cy |
| Arithmetic combination | 3 | ~3 cy | ~9 cy |
| Running accumulator update | 1 | ~4 cy | ~4 cy |
| **Total** | **~8** | — | **~60 cycles** |
O(1) per bar. LogCosh is dominated by transcendental function costs (exp, log). ~60 cycles/bar.
### Batch Mode (SIMD Analysis)
| Operation | Vectorizable? | Notes |
| :--- | :---: | :--- |
| Residual computation | Yes | Element-wise |
| exp() calls | Partial | Polynomial SIMD approximation gives 4x speedup |
| log() call | Partial | Same polynomial approximation |
| Accumulation | Yes | Parallel reduction |
Batch SIMD with polynomial exp/log: ~15-20 cy/bar.
| Metric | Score | Notes |
| :--- | :--- | :--- |
| **Throughput** | ~18 ns/bar | O(1) update, log/cosh computation |