The Hidden Power of Pure 16-bit Floating-Point Neural Networks
Lowering the precision of neural networks from the prevalent 32-bit precision
has long been considered harmful to performance, despite the gain in space and
time. Many works propose various techniques to implement half-precision neural
networks, but none study pure 16-bit settings. This paper investigates the
unexpected performance gain of pure 16-bit neural networks over the 32-bit
networks in classification tasks. We present extensive experimental results
that favorably compare various 16-bit neural networks' performance to those of
the 32-bit models. In addition, a theoretical analysis of the efficiency of
16-bit models is provided, which is coupled with empirical evidence to back it
up. Finally, we discuss situations in which low-precision training is indeed
detrimental.
Juyoung Yun, Byungkon Kang, Zhoulai Fu
# The Hidden Power of Pure 16-bit Floating-Point Neural Networks

###### Abstract

Lowering the precision of neural networks from the prevalent 32-bit precision has long been considered harmful to performance, despite the gain in space and time. Many works propose various techniques to implement half-precision neural networks, but none study _pure_ 16-bit settings. This paper investigates the unexpected performance gain of pure 16-bit neural networks over the 32-bit networks in classification tasks. We present extensive experimental results that favorably compare various 16-bit neural networks' performance to those of the 32-bit models. In addition, a theoretical analysis of the efficiency of 16-bit models is provided, which is coupled with empirical evidence to back it up. Finally, we discuss situations in which low-precision training is indeed detrimental.

Machine Learning, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Power, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden, Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden, Power, Hidden, Hidden Power, Hidden, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden, Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden, Hidden Power, Hidden, Hidden Power, Hidden, Hidden, Hidden Power, Hidden, Hidden, Power, Hidden, Hidden, Power, Hidden, Hidden, Hidden Power, Hidden, Hidden, Hidden Power, Hidden, Hidden, Hidden Power, Hidden, Hidden, Power, Hidden, Hidden, Hidden Power, Hidden, Hidden, Hidden, Power, Hidden, Hidden, Hidden Power, Hidden, Hidden, Hidden Power, Hidden, Hidden, Hidden Power, Hidden, Hidden, Hidden, Power, Hidden, Hidden, Power, Hidden, Hidden, Hidden Power, Hidden, Hidden, Hidden Power, Hidden, Hidden, Power, Hidden, Hidden, Power, Hidden, Hidden, Hidden Power, Hidden, Hidden,, Hidden Power, Hidden, Hidden,, Hidden Power, Hidden, Hidden, Hidden Power, Hidden, Hidden,, Hidden,, Hidden Power, Hidden, Hidden, Hidden,, Hidden Power, Hidden, Hidden, Hidden,,, Hidden Power, Hidden, Hidden, Hidden,,,, Hidden Power, Hidden, Hidden, Hidden,, Hidden Power, Hidden, Hidden, Hidden,,,, Hidden Power, Hidden, Hidden,, Hidden Power, Hidden, Hidden,,, Hidden Power, Hidden, Hidden, Hidden,,,, Hidden Power, Hidden, Hidden,, Hidden,,,, Hidden Power, Hidden, Hidden, Hidden,,,, Hidden Power, Hidden, Hidden, Hidden,,,, Hidden Power, Hidden, Hidden, Hidden,,,,, Hidden Power, Hidden, Hidden, Hidden,,,,, Hidden Power, Hidden, Hidden,,,, Hidden,,,, Hidden Power, Hidden, Hidden,,, Hidden,,,,, Hidden Power, Hidden, Hidden,,,,,, Hidden Power, Hidden, Hidden,,,,,, Hidden Power, Hidden, Hidden,,,,,, Hidden Power, Hidden, Hidden,,,,,, Hidden Power, Hidden, Hidden,,,,,, Hidden Power, Hidden, Hidden,,,,,, Hidden Power, Hidden, Hidden,,,,,,, Hidden Power, Hidden,, Hidden,,,,,,, Hidden Power, Hidden,,,,,, Hidden Power, Hidden,,,,,,, Hidden Power, Hidden,,,,,,, Hidden Power, Hidden,,,,,,,, Hidden Power, Hidden,,,,,,,, Hidden Power,,,,,,,,,, Hidden Power,,,,,,,,,, Hidden Power,,,,,,,,,,,, Hidden Power,,,,,,,,,,,,, Hidden Power,,,,,,,,,,,,,, Hidden Power
mixed precision algorithms like loss scaling. Our finding is positive. That is, pure 16-bit neural networks, without any floating-point 32 components, despite being imprecise by nature, can be precise enough to handle a major application of machine learning - the classification problem.

Our work first formalizes the intuitive concept of error tolerance and proposes a lemma that theoretically guarantees 16-bit "locally" achieves the same classification result as 32-bit under certain conditions. Combined with our preliminary observations, we conjecture that the 16-bit and 32-bit have close results in handling classification problems. We then validate our conjecture through extensive experiments on Deep neural network (DNN) and Constitutional Neural Network (CNN) problems. Our contributions follow:

* We aim to debunk the myth that plain 16-bit models do not work well. We demonstrate that training neural network models in pure 16 bits with no additional measures to "compensate" results in competitive, if not superior, accuracy.
* We offer theoretical insights on _why_ half precision models work well, as well as empirical evidence that supports our analysis.
* We perform extensive experiments comparing the performance of various _pure_ 16-bit neural networks against that of 32-bit and mixed precision networks and find that the 16-bit neural networks can perform as well as their 32-bit counterparts. We also identify factors that could negatively influence the success of 16-bit models.

## 2 Related Work

Several techniques have been proposed to reduce the precision of machine learning models while maintaining their accuracy to some degree. The approach that best aligns with our work is that of lowering the precision of the floating point numbers used in those models, but other approaches involve algorithm modification, fixed point formats, and hardware acceleration.

**Algorithm modification**. These approaches aim to modify certain components of the main algorithm to allow low-precision work. The work by (De Sa et al., 2017) offers a way to address the issues associated with low precision in gradient descent by assigning different precisions to the weights and the gradients. Such a scheme is assisted by special hardware implementation to speed up this mixed-precision process. A similar approach is taken by (Bjorck et al., 2021) in reinforcement learning. This work proposes various mechanisms to perform reinforcement learning on low precision reliably. For example, adopting numerical methods to improve the Adam optimization algorithm so that underflow can be prevented. Many of such techniques proposed are somewhat ad-hoc to the target problem but might also be useful in a more general setting.

**Fixed point formats**. A _fixed point format_ is another number format often used to represent real numbers, although not standard. Several other works have adopted fixed point formats to allow low precision due to the intuitive representation and high extensibility to other configurations. To verify the issues with low precision in deep learning, the authors of (Gupta et al., 2015) investigate the behavior of deep neural networks when the precision is lowered. In this work, the empirical results show that reducing the precision of the real numbers comprising the weights of the network shows a graceful degradation of accuracy. (Chen et al., 2017) performs neural network training in fixed point numbers by quantizing a floating point number into a low-precision fixed point number during training. The idea of quantizing floating point is also used in (Lin et al., 2016), where the authors approach the conversion as an optimization problem. The objective of the optimization is to reduce the network's size by adopting different bit-width for each layer. On a more system-based approach, (Kumar et al., 2020) proposes compiler support for converting floating point numbers to low-precision fixed point numbers. (Gopinath et al., 2019) also takes compiler- and language-based support for achieving low-precision numbers.

Although not entirely the same as _real_ number fixed point, integer quantization can also be considered a special fixed point format and has become a viable choice in low-precision neural network design. In (Wu et al., 2018), floating point weights are quantized to convert them into signed integer representations. The authors discover that adopting an integral quantization technique results in a regularization-like behavior, leading to increased accuracy. Similar to this approach, work by (Das et al., 2018) also proposes to use integer operations to achieve high accuracy. Such integer operations effectively convert the floating point numbers into what is known as dynamic fixed point (DFP) format. The work in (Jacob et al., 2017) also aims to quantize the weights to integers. However, the weights remain integers only during the forward pass and become floating point numbers for back-propagation to account for minute updates. Another work (Courbariaux et al., 2015) takes an extreme quantization approach to binarize the weights to -1 and 1. The weights remain binary during the forward and backward pass but become floating points during the weight update phase. (Xiao et al., 2022) adopts a post-training quantization approach to reduce the memory footprint of large-scale language models.

(Koster et al., 2017) proposes an adaptive numerical format that retains the advantages of floating and fixed point numbers. This is achieved by having a shared exponent that gets updated during training.

**Mixed precision**. On the other hand, _mixed precision_ ap
proaches maintain standard floating point numbers in two different precision. The first practically successful reduced-precision floating point mechanism was proposed by (Micikevicius et al., 2018). In this work, the authors devise a scheme to perform mixed precision training by maintaining a set of master full-precision floating point weights that serves as the 'original copy' of the half-precision counterparts. While this technique does result in reduced running time, the mixed-precision nature of it limits the performance gain achieved. (Wang et al., 2019) propose a 4-bit floating point architecture mixed with a small amount of 8-bit precision. In addition to the format, the authors devise a two-phase rounding procedure to counter the low accuracy induced by the low-precision format.

**Hardware support**. Lastly, we would like to point out that many of these works either implicitly or explicitly require hardware support due to the individual floating/fixed point formats. Most approaches typically use FPGAs and FPUs to implement these formats, but other works such as (Sharma et al., 2017) propose novel architectures tailored to addressing the bit formats of the floating point numbers. Some previously mentioned works, such as (Wang et al., 2019), also hint at the possibility of leveraging hardware assistance.

Unlike these previous works, our work focuses explicitly on the IEEE floating point format, which is the de-facto standard for general computing machinery. More precisely, we investigate the pros and cons of using a pure 16-bit IEEE floating point format in training neural networks without external support.

## 3 Background

General NotationThe real numbers and integers are denoted by \(\mathbf{R}\) and \(\mathbf{Z}\), respectively. Given a vector \(x=(x_{0},...,x_{n-1})\in\mathbf{R}^{n}\), its infinity norm or maximum norm:, denoted by \(|x|_{\infty}\), is the maximum element in the vector, namely \(|x|_{\infty}\stackrel{{\text{def}}}{{=}}\max_{i}|x_{i}|\).

### Floating-Point Representation

We write \(\mathbf{F}_{16}\) to denote the set of 16-bit floating-point numbers excluding \(\pm\infty\) and NaN (Not-a-Number). Following IEEE-754 standard (IEEE Computer Society, 2008), each \(x\in\mathbf{F}_{16}\) can be written as

\[x=(-1)^{s}\times g_{0}.g_{1}...g_{10\ (2)}\times 2^{e} \tag{1}\]

where \(s\in\{0,1\}\), \(g_{i}\in\{0,1\}\) (\(0\leq i\leq 10\)), and \(e\in\mathbf{Z}\). We call \(s\), \(g_{0}.g_{1}....g_{10}\) and \(e\) the sign, the significand, and the exponent, respectively. They satisfy \(g_{0}\neq 0\) and \(-14\leq e\leq 15\). The case where \(g_{0}=0\) and \(e=-14\) is called a subnormal number.

We write \(\mathbf{F}_{32}\) for the set of 32-bit (single-precision) floating-point numbers excluding \(\pm\infty\) and NaN. The following property holds:

\[\mathbf{F}_{16}\subset\mathbf{F}_{32}\subset\mathbf{R} \tag{2}\]

Namely, a 16-bit or 32-bit floating-point number is a real, and a 16-bit can be exactly represented as a 32-bit (by padding with zeros). Tab. 3 lists the range and the precision of 16-bit and 32-bit floating-point numbers.

### Floating-point Errors

Rounding is necessary when representing real numbers that cannot be written as Eq. 1. _Rounding error_ of a real \(x\) at precision \(p\) refers to \(|x-\circ_{p}(x)|\) where the rounding operation, \(\circ_{p}:\mathbf{R}\rightarrow\mathbf{F}_{p}\), defines the nearest floating-point number of \(x\). Namely, \(\circ_{p}(x)\stackrel{{\text{def}}}{{=}}\operatorname*{argmin}_{y \in\mathbf{F}_{p}}|x-y|\). 1 Rounding error is usually small, on the order of machine epsilon (Tab. 3.1), but it can be propagated and become more significant. For example, the floating-point code sin(0.1) goes through three approximations. First, 0.1 is rounded to the floating-point \(\circ_{p}(0.1)\) for some precision \(p\). Then, the rounding error is _propagated_ by the floating-point code sin. Lastly, the calculation output is rounded again if an exact representation is not possible.

Footnote 1: For simplicity, this definition of the rounding operation ignores the case where a tie needs to be broken.

Floating-point errors are usually measured in _absolute error_ or _relative error_. This paper focuses on classification problems where output numbers are probabilities between 0 and 1. Thus, we use the absolute error \(|x-y|\) for quantifying the difference between two floating point numbers \(x\) and \(y\).

## 4 Theory

Suppose \(M_{16}\) and \(M_{32}\) are 16-bit and 32-bit deep learning models trained by the same neural network architecture and hyper-parameters. By abuse of notation, we consider \(M_{16}\) and \(M_{32}\) as classifiers or functions that return the probability vector from the last layer given an input \(x\) (e.g., an image).

Let \(x\) be an arbitrarily chosen input. Suppose \(M_{32}(x)\) returns \((p_{0},\cdots,p_{N-1})\), and \(M_{16}(x)\) returns \((p_{0}^{\prime},\cdots,p_{N-1}^{\prime})\). Clearly, the classification result of an input \(x\) made by a clas

\begin{table}
\begin{tabular}{l c c c} \hline \hline Type & Size & Range & Machine-epsilon \\ \hline Half & 16 bits & 6.55E\(\pm\)4 & 4.88E-04 \\ Single & 32 bits & 3.4E\(\pm\)38 & 5.96E-08 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Some characteristics of the 16-bit and 32-bit floating-point formats.
sifier \(M\) is given as

\[\text{pred}(M,x)\stackrel{{\text{def}}}{{=}}\operatorname{argmax}_{i} \{p_{i}|p_{i}\in M(x)\}. \tag{3}\]

Due to the floating-point error, the classification results of \(M_{32}\) and \(M_{16}\) on \(x\) can be different. To quantify this difference, we define the _floating point error_ as follows.

**Definition 4.1**.: Given the 16-bit classifer \(M_{16}\), the 32-bit \(M_{32}\), and an input \(x\), the _floating point error_ between the classifiers is given as

\[\delta(M_{32},M_{16},x)\stackrel{{\text{def}}}{{=}}|M_{32}(x)-M_ {16}(x)|_{\infty} \tag{4}\]

The degree to which this difference affects the outcome is an important question we investigate in this work. In fact, we can show a sufficient condition (denoted by C) that guarantees the absence of difference between two classifiers.

**(C.)**: If the difference between the largest of \(p_{i}\) and the second largest is greater than twice the floating point error, then the two classifiers \(M_{16}\) and \(M_{32}\) have the same classification result on \(x\).

Illustration for condition (C): suppose \(M_{32}(x)=(0.8,0.1,0.05,0.05)\) for a classification problem of four labels. Let the largest error between this probability vector and \(M_{16}(x)\) be \(\delta\). Then in the worst case, 0.8 can drop to \(0.8-\delta\) for the 16-bit, and the second largest probability becomes \(0.1+\delta\). If \(0.8-\delta>0.1+\delta\), then \(M_{16}\) and \(M_{32}\) must have the same classification result on \(x\), e.g., \(M_{16}(x)=(0.7,0.15,0.1,0.05)\).

Below, we formalize condition (C) following introduction of the notion of _error tolerance_.

**Definition 4.2**.: The _error tolerance_ of a classifier \(M\) with respect to an input \(x\) is defined as the gap between the largest probability and the second-largest one:

\[\Gamma(M,x)\stackrel{{\text{def}}}{{=}}p_{0}-p_{1}, \tag{5}\]

where \(p_{0}=|M(x))|_{\infty}\), and \(p_{1}=|M(x)\backslash p_{0}|_{\infty}\).

Here, \(M_{32}(x)\backslash p_{0}\) refers to a vector of elements in \(M_{32}(x)\) but with \(p_{0}\) removed. The error tolerance can be thought of as quantifying the stability of the prediction. We have the following lemma corresponding to condition C.

**Lemma 4.3**.: Consider a classification problem characterized by a pair \((X,Y)\) where \(X\) is the space of input data, and \(Y=\{0,..N-1\}\) is the labels of classification. Suppose a learning algorithm trains a 32-bit model \(M_{32}:X\rightarrow\mathbf{F}_{32}^{N}\) and a 16-bit model \(M_{16}:X\rightarrow\mathbf{F}_{16}^{N}\) on a dataset \(D\subseteq X\times Y\).

We have: If

\[\Gamma(M_{32},x)\geq 2\delta(M_{32},M_{16},x) \tag{6}\]

then \(\operatorname{pred}(M_{32},x)=\operatorname{pred}(M_{16},x)\).

Proof.: Let \(M_{32}(x)\) be \((p_{0},....p_{N-1})\). Without loss of generality we assume \(p_{0}\) is the largest one in \(\{p_{i}\}\) (\(0\leq i\leq N-1\)). We denote \(\delta(M_{32},M_{16},x)\) by \(\delta\) hereafter. Following Eq. 6, we have

\[\forall i\in\{1,...,N-1\},p_{0}-p_{i}\geq 2\delta. \tag{7}\]

Let \(M_{16}(x)\) be \((p^{\prime}_{0},....p^{\prime}_{N-1})\). Then for each \(i\in\{1,...,N-1\}\), we have

\[p^{\prime}_{0} \geq p_{0}-\delta\] By Eq. 4 and Def. of \[p_{0},p^{\prime}_{0}\] \[\geq p_{i}+\delta\] By Eq. 5 and Eq. 7 \[\geq p^{\prime}_{i}\] By Eq. 4

Thus \(p^{\prime}_{0}\) remains the largest in the elements of \(M_{16}(x)\)

\begin{table}
\begin{tabular}{l l l l l l l l l} \hline \hline  & \multicolumn{4}{c}{Floating-point error} & \multicolumn{4}{c}{Error tolerance} \\ \cline{2-9} Epochs & Min & Max & Mean & Variance & Min & Max & Mean & Variance \\ \hline
10 & 0.00E+00 & 1.68E-01 & 2.76E-03 & 5.62E-05 & 9.29E-05 & 1.00E+00 & 7.66E-01 & 7.58E-02 \\
20 & 7.84E-15 & 2.07E-01 & 2.88E-03 & 8.53E-05 & 3.65E-05 & 1.00E+00 & 8.24E-01 & 6.31E-02 \\
50 & 0.00E+00 & 3.82E-01 & 3.69E-03 & 1.97E-04 & 2.74E-06 & 1.00E+00 & 8.79E-01 & 4.72E-02 \\
100 & 0.00E+00 & 5.64E-01 & 4.12E-03 & 3.27E-04 & 3.24E-04 & 1.00E+00 & 9.16E-01 & 3.42E-02 \\
200 & 0.00E+00 & 6.75E-01 & 4.23E-03 & 4.76E-04 & 1.93E-04 & 1.00E+00 & 9.47E-01 & 2.19E-02 \\
500 & 0.00E+00 & 9.35E-01 & 3.76E-03 & 6.18E-04 & 1.44E-03 & 1.00E+00 & 9.79E-01 & 7.72E-03 \\
1000 & 0.00E+00 & 9.95E-01 & 3.14E-03 & 5.77E-04 & 1.91E-03 & 1.00E+00 & 9.91E-01 & 2.98E-03 \\ \hline \hline \end{tabular}
\end{table}
Table 2: The columns of “Floating-point errors” and “Error tolerance” refer to statistics of \(\delta(M_{32},M_{16},x)\) and \(\Gamma(M32,x)\) respectively, where \(x\) ranges over the images of the MNIST dataset.
Below we illustrate Lemma 4.3 through a simple neural network trained on MNIST. Our 32-bit implementation has three Dense layers followed by a softmax layer at the end. Our 16-bit implementation uses the same architecture, except all floating-point operations are performed on 16-bit.

Table 4 shows our results of error tolerance \(\Gamma\) and floating-point error \(\delta\). Observe that the mean floating-point error is of the magnitude of 1E-3 with a variance of 1E-5 or 1E-4; the error tolerance is 1E-1 with a variance of 1E-2. Thus, one can argue that Eq. 6, namely, \(\Gamma>2\delta\), holds for most data in MNIST. The table also shows that floating-point errors can be larger than the tolerance in some corner cases. Thus, we expect our 16-bit and 32-bit implementations to have close but different accuracy results.

Results at training and testing are presented. Table 4 shows the accuracy and loss results in MNIST comparing 16-bit and 32-bit implementations. We can see consistently that the 16-bit results have accuracy close to those of the 32-bit models, sometimes even better. This result motivates us to study whether the 16-bit model is similar to the 32-bit model for more complex neural networks.

In theory, if 80% of data in a dataset satisfy Eq. 6, Lemma 4.3 tells us that the 32-bit and 16-bit models will have at least 80% of classification results being the same. The main challenge here is that we cannot determine if Eq. 6 always holds or the percentage of data that satisfies it. We believe that for complex neural networks, most data meet Eq. 6. This is because the loss function for the classification problem is a cross-entropy in the form of \(-\Sigma\log(p_{i})\), which should guide \(p_{i}\) toward \(1\) during training and in turn, causes a large error tolerance \(\Gamma\) compared to relatively small \(\delta\). In fact, Table 4 shows that the floating point errors (\(\delta\)'s) are nearly two orders of magnitude smaller than the \(\Gamma\)'s. Although the gap might close over the epochs, the difference remains sufficiently large to satisfy the condition of the lemma.

With this theoretical development and observations, we propose the following conjecture.

The accuracy of a 16-bit neural network for classification problems, in the absence of significant errors involving floating-point overflow/underflow, will be close to that of a 32-bit neural network.

We anticipate a situation where floating-point errors can become significant due to overflow or underflow since 16-bit floating-point is known to have a smaller range (Table 3.1). The conjecture may be surprising, so we devote our next section to in-depth validation.

## 5 Experiments

We aim to compare the performance of 16-bit operations to 32-bit operations in deep neural network (DNN)2 and convolutional neural network (CNN) models. we experiment over three CNN models, including AlexNet (Krizhevsky et al., 2012), VGG16 (Simonyan and Zisserman, 2015), and ResNet-34 (He et al., 2016). We will see how the different precision settings affect the computational time and accuracy of the models. Unlike case studies in the previous section, we use 100 epochs for all experiments and gradually increase the batch size from 64 to 384 to see how it affects 16-bit training. All random seeds used in this study's experiments are fixed to facilitate the comparison. The experiments were conducted on NVIDIA's RTX3080 Laptop GPU.

Footnote 2: While DNNs subsume CNNs, we use the term DNN to refer to fully-connected, non-convolutional neural networks.

Table 4 gives the result most representative of our work. A more detailed description and analysis of these results will follow in the subsequent subsections.

\begin{table}
\begin{tabular}{l c c c c c c c c} \hline \hline  & \multicolumn{2}{c}{Train accuracy} & \multicolumn{2}{c}{Test accuracy} & \multicolumn{2}{c}{Train loss} & \multicolumn{2}{c}{Test loss} \\ \cline{2-9} Epochs & 32-bit & 16-bit & 32-bit & 16-bit & 32-bit & 16-bit & 32-bit & 16-bit \\ \hline
10 & 90.3\% & 90.0\% & 90.8\% & 91.0\% & 3.49E-01 & 3.69E-01 & 3.23E-01 & 3.39E-01 \\
20 & 92.2\% & 92.3\% & 92.8\% & 92.8\% & 2.71E-01 & 2.94E-01 & 2.57E-01 & 2.74E-01 \\
50 & 94.9\% & 95.3\% & 94.9\% & 94.7\% & 1.81E-01 & 2.10E-01 & 1.80E-01 & 2.04E-01 \\
100 & 96.7\% & 96.4\% & 96.3\% & 95.8\% & 1.16E-01 & 1.49E-01 & 1.28E-01 & 1.52E-01 \\
200 & 98.4\% & 97.3\% & 97.4\% & 97.3\% & 6.05E-02 & 9.32E-02 & 8.97E-02 & 1.10E-01 \\
500 & 99.8\% & 99.1\% & 97.7\% & 98.1\% & 1.38E-02 & 4.00E-02 & 7.87E-02 & 8.54E-02 \\
1000 & 100.0\% & 99.8\% & 97.8\% & 98.1\% & 2.97E-03 & 2.04E-02 & 9.02E-02 & 8.29E-02 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Comparing accuracy and loss results between 32-bit and 16-bit neural networks on the MNIST dataset.
Figure 1: Top-1 accuracy (top row) and computational time (bottom row) on MNIST Classification using DNN

Figure 2: Top-1 Accuracy, Top-2 Accuracy, and Computational Time for Cifar-10 Classification
### DNN Experiments

In the DNN experiments, we train a DNN with three hidden layers to perform the MNIST classification task and compare the performances between those of the 16-bit model and the 32-bit model. Each of the three layers in the DNN has 4096 neurons, whose outputs are fed to the next layer after passing through ReLU activation. Other works, such as (Micikevicius et al., 2018), use a 32-bit softmax layer regardless of the overall precision settings to prevent potential numerical instability, but we leave stick with a 16-bit softmax to see how a "pure" 16-bit model fares against 32-bit ones. We also vary the types of optimizers among RMSProp, Adam, and SGD to examine their effects on performance. In addition, we confirm from this experiment that not only SGD but also other optimizers, such as RMSProp and Adam, can be used in 16-bit if \(\epsilon\) is properly set.

In all experiments in this section, we use the learning rate of \(10^{-3}\) and fix \(\epsilon\) in RMSProp and Adam to \(10^{-3}\) as well. We direct readers to the Appendix for experiments in other settings. Finally, in addition to the 32-bit baseline, we also compare the mixed-precision training algorithm proposed by (Micikevicius et al., 2018) (as provided by TensorFlow). Figure 1 shows that 16-bit deep neural networks are better than 32-bit and mixed precision in terms of computational time while maintaining similar test accuracy. In detail, (see Figure 3 in the Appendix) 16-bit SGD's computational time is decreased by 40.9%, and the test accuracy was increased 0.6%, respectively, compared to 32-bit while 16-bit computational time was decreased by 59.8% and accuracy was increased 0.59% compared to mixed precision when the batch size was the smallest at 64. Other batch sizes yielded consistent trends, albeit with smaller magnitude (Keskar et al., 2017).

Optimization-wise, 16-bit RMSProp reduced the runtime by 40.4% and 59.6% compared to 32-bit and mixed, respectively, and accuracy is increased by 0.3% and 0.4%. 16-bit Adam improved the runtime by 41.6% and 58.1%, and 6.4% and 7.5% in terms of accuracy compared to 32-bit and mixed precision, respectively. Of the total of 33 experimental groups calculated with three optimizers, 31 decreased running time by more than 40% compared to 32 bits while maintaining the accuracy to a similar level. Every computational time and test accuracy in 16-bit deep neural networks is better than those of 32-bit and mixed precision.

### CNN Experiments

16-bit CNN experiments were conducted to determine whether 16-bit is enough for training a more complex image classification problem and how numerically different it is from 32-bit. We used the CIFAR10 dataset and three convolutional neural networks (CNN) models: AlexNet, VGG16, and ResNet-34. All of these experiments were carried out using Adam in a 16-bit environment. Since the batch normalization (BN) layer is not implemented as an off-the-shelf module in 16 bits, the experiment was conducted focusing on CNN models that could be used without the batch normalization layer. See the Appendix for treatment on 16-bit BN implementations.

#### 5.2.1 Training Time and Accuarcy

Figure 1 shows that 16-bit CNNs are better than 32-bit and mixed precision in terms of computational time and test accuracy. Figure 2 shows that 16-bit operations can also be applied to CNN models for image classification. We found that 16-bit CNNs maintain similar accuracy to 32-bit.

AlexNetAt the smallest batch size of 64, 16-bit AlexNet's top-1 and top-2 accuracy results are increased by 0.9% and 0.6% compared to 32-bit, respectively, and training time decreased by 29.1%. The running time of 16-bit AlexNet is reduced by more than 29% compared to its 32-bit counterpart.

WGG-16In terms of top-1 and top-2 accuracy, 16-bit VGG16 increased by 1.6% and 0.6% compared to 32-bit, respectively, and learning time decreased by 43.7%. All computational speeds of 16-bit VGG16 were decreased by more than 40% compared to 32-bit.

ResNet-3416-bit ResNet-34 decreased 0.6% and 0.4% in terms of top-1 and top-2 accuracy, and computational time decreased 44.7% compared to 32-bit. The running time of 16-bit ResNet-34 were reduced by more than 39%.

Overall, a 2.6% (AlexNet, Batch Size: 384) decrease in 16-bit top1-accuracy compared to 32-bit in 33 experimental sets was the largest decrease, and the largest increase is 2.7% (ResNet-34, Batch Size: 192). The smallest decrease in running time is by 29.1% (AlexNet, Batch Size: 64) compared to 32 bits, and 45.6% (VGG16, Batch Size: 288) the largest decrease. In other words, all 16-bit experimental groups used in all experiments decreased their computational speed by at least 29.1%.

This experiment shows that by using 16-bit operations in

\begin{table}
\begin{tabular}{c c c c} \hline \hline Model & Results & FP32 & FP16 \\ \hline AlexNet & Time & 381s & 270s \\  & Accuracy & 68.9\% & 69.5\% \\ \hline VGG16 & Time & 1445s & 812s \\  & Accuracy & 82.9\% & 84.3\% \\ \hline ResNet-34 & Time & 1914s & 1058s \\  & Accuracy & 76.6\% & 76.1\% \\ \hline \hline \end{tabular}
\end{table}
Table 4: Summary of the time and accuracy performances of the three CNNs.
image classification with CNN models, the running time (whether training or testing) can be greatly reduced while maintaining similar or higher accuracy compared to 32-bit operations. Our results demonstrate the efficiency of neural networks in training CNN models in a low-precision setting.

#### 5.2.2 Model Size

The preservation of the trained model weights is an important aspect of contemporary deep learning.

It is useful for model training and storage if a model with similar accuracy has less storage size. Table 5 shows the stored model has about half the size of the 32-bit size, faithfully reflecting the half-precision size reduction. 16-bit neural network allows for reducing the size of the model by half while maintaining similar accuracy. This opens up possibilities for 16-bit models to afford more complex and accurate architectures to attain better results.

### Limitation and Discussion

This subsection reports the limitations we find while using the 16-bit neural network.

Light hyperparameter-tuning.During our experiments, we do not need to tune hyperparameters of 16-bit neural network training, e.g. learning rates, except the epsilon in the settings of the optimizers. The SGD (Goodfellow et al., 2016) optimizer does not have epsilon, so it can be used directly. For the other optimizers we have tested in our experiments, RMSProp (Hinton et al.) and Adam (Kingma & Ba., 2015), we will need to change epsilon, whose default value (in Tensorflow), 1E-7, can easily trigger significant inaccuracy for 16-bit training.

As a detail, the parameter epsilon corresponds to \(\epsilon\) in the weight updates below:

RMSProp : \[w_{t}= w_{t-1}-\eta\frac{g_{t}}{\sqrt{v_{t}}+\epsilon}\] ADAM : \[w_{t}= w_{t-1}-\eta\frac{\hat{m_{t}}}{\sqrt{\hat{v_{t}}}+\epsilon}\]

These optimizers introduced \(\epsilon\) in to enhance numerical stability, but \(\epsilon\) = 1E-7 in the denominator causes floating-point overflow when \(v_{t}\) in RMSProp or \(\hat{v_{t}}\) in Adam are close to 0. As mentioned previously, we set \(\epsilon\) = 1E-3 for 16-bit training.

Missing 16-bit Batch normalization.Tensorflow's current batch normalization layer does not directly support pure 16-bit operations. The batch normalization layer presumably originates from mixed precision works, which would cast 16-bit input values to 32-bit for calculation and then downcast to 16 bits. This type conversion only results in runtime overhead due to the intermediate 32-bit computation.

Since this work aims to report results on pure 16-bit neural networks, we have to implement a 16-bit batch normalization layer on our own. Our implementation of the 16bit batch normalization can be found in Appendix.

Batch size.Our CNN experiments show that the accuracy of 16-bit neural networks decreases in larger batch sizes. This can be due to the precision loss incurred when averaging the cost over a larger number of samples in the mini-batches. This is probably a minor limitation since neural networks in memory-constrained environments usually do not use large batch sizes.

Despite these limitations, we have confirmed that 16-bit neural networks learn as well as 32-bit with only minor fine-tuning (\(\epsilon\) in the optimizers). Thus, we believe ML practitioners can readily benefit from 16NN when it comes to solving op optimization problems since it is faster, less memory-consuming, yet achieves similar accuracy as the 32-bit. Instead of spending the same amount of time and space as 32-bit, we can form a network with an enhanced cost-to-benefit ratio.

## 6 Conclusion

In this work, we have shown that for classification problems, the 16-bit floating-point neural network can have an accuracy close to the 32-bit. We have proposed a conjecture on their accuracy closeness and have validated it theoretically and empirically. Our experiments also suggest a small amount of accuracy gain, possibly due to the regularizing effect of lowering the precision. These findings show that it is much safer and more efficient to use 16-bit precision than what is commonly perceived: the runtime and memory consumption is lowered significantly with little or no loss in accuracy. In the future, we plan to expand our work to verify similar characteristics in other types of architectures and problems such as generative models and regression.
