Accurate Computation of the Log-Sum-Exp and Softmax Functions

09/08/2019
by   Pierre Blanchard, et al.
0

Evaluating the log-sum-exp function or the softmax function is a key step in many modern data science algorithms, notably in inference and classification. Because of the exponentials that these functions contain, the evaluation is prone to overflow and underflow, especially in low precision arithmetic. Software implementations commonly use alternative formulas that avoid overflow and reduce the chance of harmful underflow, employing a shift or another rewriting. Although mathematically equivalent, these variants behave differently in floating-point arithmetic. We give rounding error analyses of different evaluation algorithms and interpret the error bounds using condition numbers for the functions. We conclude, based on the analysis and numerical experiments, that the shifted formulas are of similar accuracy to the unshifted ones and that the shifted softmax formula is typically more accurate than a division-free variant.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
01/27/2021

Probabilistic Error Analysis For Sequential Summation of Real Floating Point Numbers

We derive two probabilistic bounds for the relative forward error in the...
research
05/11/2022

An Efficient Summation Algorithm for the Accuracy, Convergence and Reproducibility of Parallel Numerical Methods

Nowadays, parallel computing is ubiquitous in several application fields...
research
07/04/2021

Deterministic and Probabilistic Error Bounds for Floating Point Summation Algorithms

We analyse the forward error in the floating point summation of real num...
research
01/02/2022

High Precision Computation of Riemann's Zeta Function by the Riemann-Siegel Formula, II

(This is only a first preliminary version, any suggestions about it will...
research
01/13/2020

The Two-Pass Softmax Algorithm

The softmax (also called softargmax) function is widely used in machine ...
research
11/26/2018

Sound Approximation of Programs with Elementary Functions

Elementary function calls are a common feature in numerical programs. Wh...
research
05/11/2020

Computationally Inequivalent Summations and Their Parenthetic Forms

Floating-point addition on a finite-precision machine is not associative...

Please sign up or login with your details

Forgot password? Click here to reset