# Lossless Compression of Sensor Signals Using an Untrained Multi-Channel Recurrent Neural Predictor
## 2 Context-Based Lossless Compression for Sensor Signals
### Context-Based Encoding and Decoding  
The proposed approach in this paper is built upon a context-based lossless compression framework which consists of a predictor and a coding module. Specifically, we use entropy coding as the coding module, and a sequence predictor is used to give the probability prediction, as in Equation (2). Here we summarize the general flow of such a context-based encoding and decoding scheme, as shown in Figure 1. At each encoding/decoding step \(t\), the predictor first reads \(K\) latest data points \(\{x_{t-K},\cdots,x_{t-1}\}\) from raw data and gives a prediction \(\mathbf{p}_{t}\). This prediction is then sent to the entropy coding module to encode raw data \(x_{t}\), or decode compressed data \(\hat{x}_{t}\). For some context-based compressors, the predictor will be updated based on the true value, i.e., \(x_{t}\), of the prediction made. In this paper, all mentioned context-based compressors, including the proposed approach, use arithmetic coding [10] as the entropy coding module, unless otherwise specified. Among the context-based approaches, the ones based on the LZ77 algorithm [12], which uses a dictionary to maintain the context of data, are perhaps the most widely used. For example, the famous compression tool Gzip, to which our proposed method is compared in Section 4, is based on LZ77 and Huffman coding [9]. Another popular LZ77-based compressor, namely LZMA, uses arithmetic coding as the entropy coding module. These compressors work without the prior knowledge of the data to be compressed. In addition, they are not able to model the underlying joint distributions of data points, leading to a relatively low compression rate (see Table 1). To address this issue, CMIX [15] combines a large number of context-based predictors, achieving a state-of-the-art compression ratio on several compression benchmarks [22; 23] at the cost of slow compression speed. Deep learning models, especially recurrent neural networks (RNNs), have been proven to be good at modeling context information hidden in sequential data. Naturally, they can be used as probability predictors in context-based compressors. DZip [17] uses a single deep learning model as the probability predictor. At each time step \(t\), it calculates the conditional \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Name** & **Gzip** & **BSC** & **PAQ** & **CMIX** & **Ours** \\ \hline BLOND-1 & 1.644 & 4.348 & 4.658 & 4.869 & 4.684 \\ BLOND-2 & 1.627 & 4.215 & 4.508 & 4.753 & 4.577 \\ BLOND-3 & 1.594 & 4.012 & 4.295 & 4.655 & 4.896 \\ BLOND-4 & 1.600 & 4.107 & 4.418 & 4.651 & 4.487 \\ BLOND-5 & 1.491 & 3.196 & 3.474 & 3.662 & 3.584 \\ \hline ESC-0 & 1.631 & 2.309 & 2.812 & 3.177 & 3.344 \\ ESC-1 & 2.070 & 2.491 & 3.108 & 3.431 & 3.651 \\ ESC-2 & 1.437 & 1.734 & 2.039 & 2.206 & 2.297 \\ ESC-3 & 1.388 & 1.743 & 2.166 & 2.382 & 2.501 \\ ESC-4 & 1.299 & 1.519 & 1.854 & 2.083 & 2.164 \\ \hline MPACT-DJI & 1.357 & 1.564 & 2.117 & 2.342 & 2.390 \\ MPACT-FlySky & 1.367 & 1.863 & 2.142 & 2.457 & 2.553 \\ MPACT-Futaba & 1.399 & 1.904 & 2.162 & 2.472 & 2.564 \\ MPACT-Graupner & 1.382 & 1.892 & 2.204 & 2.477 & 2.560 \\ MPACT-HobbyK & 1.300 & 1.766 & 2.102 & 2.380 & 2.446 \\ \hline DJI-14 bits & 1.109 & 1.272 & 1.670 & 1.916 & 2.090 \\ FlySky-14 bits & 1.103 & 1.420 & 1.777 & 2.004 & 2.219 \\ Futaba-14 bits & 1.117 & 1.474 & 1.806 & 2.026 & 2.234 \\ Graupner-14 bits & 1.144 & 1.407 & 1.792 & 2.037 & 2.230 \\ HobbyK-14 bits & 1.083 & 1.303 & 1.659 & 1.924 & 2.156 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: The CR results of the tested compressors. Figure 1: Working flow of a context-based lossless compressor with a probability predictor and an entropy-coding module. probability distribution based on previously observed \(K\) symbols. However, DZip requires pre-training the neural network, and the trained model is stored as a part of the compressed data in order to achieve a better compression rate. The aforementioned CMIX compressor also contains a deep learning predictor based on long short-term memory (LSTM, [16]).