Memory-efficient particle filter recurrent neural network for object
  localization
This study proposes a novel memory-efficient recurrent neural network (RNN)
architecture specified to solve the object localization problem. This problem
is to recover the object states along with its movement in a noisy environment.
We take the idea of the classical particle filter and combine it with GRU RNN
architecture. The key feature of the resulting memory-efficient particle filter
RNN model (mePFRNN) is that it requires the same number of parameters to
process environments of different sizes. Thus, the proposed mePFRNN
architecture consumes less memory to store parameters compared to the
previously proposed PFRNN model. To demonstrate the performance of our model,
we test it on symmetric and noisy environments that are incredibly challenging
for filtering algorithms. In our experiments, the mePFRNN model provides more
precise localization than the considered competitors and requires fewer trained
parameters.
Roman Korkin, Ivan Oseledets, Aleksandr Katrutsa
# Memory-efficient particle filter recurrent neural network for object localization

###### Abstract

This study proposes a novel memory-efficient recurrent neural network (RNN) architecture specified to solve the object localization problem. This problem is to recover the object states along with its movement in a noisy environment. We take the idea of the classical particle filter and combine it with GRU RNN architecture. The key feature of the resulting memory-efficient particle filter RNN model (mePFRNN) is that it requires the same number of parameters to process environments of different sizes. Thus, the proposed mePFRNN architecture consumes less memory to store parameters compared to the previously proposed PFRNN model. To demonstrate the performance of our model, we test it on symmetric and noisy environments that are incredibly challenging for filtering algorithms. In our experiments, the mePFRNN model provides more precise localization than the considered competitors and requires fewer trained parameters.

## 1 Introduction

We consider the object localization problem and propose a novel GRU-like architecture to solve it. Typically standard GRU-like models [1] are used to process sequential data, e.g. to predict the next item in a sequence, and classify or generate texts, audio, and video data. The object localization problem differs from the aforementioned problems since auxiliary data about the environment and particular measurements are available. Therefore, this additional knowledge should be incorporated into the GRU architecture properly. Such a modification can be based on the existing approaches to solve the object localization problem, which are discussed further.

One of the classical non-parametric methods to solve the object localization problem is particle filter [2], which estimates the filtered object state from the states of auxiliary artificial objects that are called particles. A modification of GRU and LSTM recurrent neural networks with particle filter ingredients is presented in [3], where a particle filter recurrent neural network (PFRNN) is proposed. The core element of PFRNN is the modified cell (GRU or LSTM) equipped with analogs of particles and the corresponding weights of particles to estimate the filtered state. However, PFRNN improves the performance of the general sequential data processing and does not consider specific features of the object localization problem. Therefore, we propose the novel _memory-efficient PFRNN (mePFRNN)_ that combines the model assumptions used in the classical filtering methods (e.g. Kalman filter and particle filter) and parametrization from the GRU architecture. Such a combination provides more accurate state estimation and improves robustness in noisy and symmetric environments. Also, the Soft resampling procedure is used to avoid the degeneracy issue and improve the stability of the filtered states.

The main contributions of our study are the following.

1. We propose a modification of the PFRNN architecture specified for the object localization problem. The proposed mePFRNN model does not exploit environment embeddings and extracts this data implicitly in the training stage.
2. We perform an extensive experimental comparison of the proposed GRU-like architecture with the existing recurrent neural networks and other non-parametric methods like the particle filter.
3. The proposed mePFRNN model requires the same number of parameters for environments of different sizes.

Related works.The object localization problem appears in a lot of applications like driving autonomous vehicles [4], navigation [5, 6], image processing [7], finance [8] and fatigue predictions [9]. Therefore, there are a lot of different approaches to solving it. We can split them into two classes: non-parametric and parametric. The first class consists of classical methods that do not require a training stage and perform filtering of the object states on the fly. Examples of such methods are Kalman filter [10, 11], and its modifications like extended [12], unscented [13], invariant extended [14] and ensembled [15] Kalman filters. Also, methods related to the particle filter, e.g. multiparticle Kalman filter [16], particle filters combined with genetic algorithms [17], and particle swarm technique [18], box particle filter [19] and others are non-parametric filtering methods. The second class consists of parametric methods such that a pre-training stage is necessary before starting filtering. Such methods are typically based on neural networks that are trained on the collected historical data and then tested on the new data from real-world simulations. Although the pre-training stage may require a lot of time, one can expect that the inference stage, in which filtering is performed, is sufficiently fast due to modern hardware acceleration. Moreover, since the neural network models can efficiently treat sequential data [20, 21], the parametric methods can provide more accurate filtering results compared to non-parametric methods.

Although the Transformer model [22] demonstrates superior performance over the considered GRU RNN in sequence processing tasks, it consumes a lot of memory to store parameters, requires special techniques for training [23] and may not fit in the on-device memory limits. The memory-efficient Transformer models [24, 25, 26] may be a remedy for the observed issue and will be investigated in future work.

## 2 Problem statement

Consider the trajectory of object states encoded as a sequence of \(d\)-dimensional vectors \(\mathbf{x}_{i}\in\mathbb{R}^{d}\), where \(i\) is an index of the time moment \(t_{i}\). For example, if the object's state consists of 2D coordinates and 2D velocity, then state dimension \(d=4\). The states are changed according to the motion equation, which combines the physical law and the control system of the object. Formally we can write the motion equation as follows

\[\mathbf{x}_{i}=f(\mathbf{x}_{i-1},\mathbf{u}_{i},\boldsymbol{\eta}_{i}), \tag{1}\]

where \(\mathbf{u}_{i}\) is a vector of control at the time moment \(t_{i}\), for example, external forces, and \(\boldsymbol{\eta}_{i}\) is a vector of noise corresponding to the object motion at the time moment \(t_{i}\). Since the object moves with some noise, we should use additional measurements to estimate states more precisely. Typically there are several beacons in the environment, which are used by objects to measure some quantities that can improve their state estimate. For example, distance to the \(k\)-nearest beacons can improve the estimate of the object's location. Formally, denote by \(\mathbf{y}_{i}\in\mathbb{R}^{k}\) a vector of measurements at time moment \(t_{i}\) that is related with state estimate through the measurement function \(g:\mathbb{R}^{d}\rightarrow\mathbb{R}^{k}\):

\[\mathbf{y}_{i}=g(\mathbf{x}_{i},\boldsymbol{\zeta}_{i}), \tag{2}\]

where \(\boldsymbol{\zeta}_{i}\) is the additional noise of measurement.

Object localization problem is the problem of estimating object trajectory from the given motion and measurement functions that represent the physical law of the environment and beacons' configuration, respectively. In this study, we introduce the parametric model \(h_{\boldsymbol{\theta}}:\mathbb{R}^{d}\times\mathbb{R}^{k}\times\mathbb{R}^{ n}\rightarrow\mathbb{R}^{d}\) that depends on the unknown parameters \(\boldsymbol{\theta}\in\mathbb{R}^{n}\) and performs filtering of the inexact state estimate \(\mathbf{x}_{i}\) based on the additional measurements \(\mathbf{y}_{i}\). Assume we have training trajectory of the ground-truth states \(\{\mathbf{x}_{i}^{*}\}_{i=1}^{N}\). Then we can state the optimization problem to fit our parametric model to the training data \(\{\mathbf{x}_{i}^{*}\}_{i=1}^{N}\) and evaluate the generalization ability of the resulting model. In particular, the standard loss function in such a problem is the mean square error loss function

\[MSE=\frac{1}{N}\sum_{i=1}^{N}\|h_{\boldsymbol{\theta}}(\mathbf{x}_{i},\mathbf{ y}_{i})-\mathbf{x}_{i}^{*}\|_{2}^{2} \tag{3}\]

such that the motion function \(f\) and the measurement functions \(g\) give the state estimate \(\mathbf{x}_{i}\) and measurement vector \(\mathbf{y}_{i}\), respectively.

We further focus on the plane motion setup, where the state vector consists of 2D coordinates \(\mathbf{c}\in\mathbb{R}^{2}\) and a heading \(\alpha\in[0,2\pi]\), which defines the direction of movement, i.e. \(\mathbf{x}=[\mathbf{c},\alpha]\in\mathbb{R}^{3}\). Therefore, we follow [3] in slightly
adjusting the MSE objective function (3) to treat coordinates and angles separately and compose the weighted MSE loss function:

\[wMSE=\underbrace{\frac{1}{N}\sum_{i=1}^{N}\|\mathbf{c}_{i}-\mathbf{c}_{i}^{*}\|_ {2}^{2}}_{=\mathrm{MSE}_{c}}+\frac{\beta}{N}\sum_{i=1}^{N}(\alpha_{i}-\alpha_{i }^{*})^{2},\quad\text{where}\quad[\mathbf{c}_{i},\alpha_{i}]=h_{\boldsymbol{ \theta}}(\mathbf{x}_{i},\mathbf{y}_{i}),\quad\mathbf{x}_{i}^{*}=[\mathbf{c}_{ i}^{*},\alpha_{i}^{*}], \tag{4}\]

where \(\beta>0\) is a given weight. However, the \(wMSE\) loss function treats angles \(2\pi-\epsilon\) and \(\epsilon\) as essentially different while they are physically close. Thus, we propose a novel modification of the mean squared loss function (3), that treats headings differently. In particular, we compare not angles but their sine and cosine in the following way:

\[L(\boldsymbol{\theta})=\mathrm{MSE}_{c}+\frac{\beta}{N}\sum_{i=1}^{N}\left[( \sin\alpha_{i}-\sin\alpha_{i}^{*})^{2}+(\cos\alpha-\cos\alpha_{i}^{*})^{2} \right], \tag{5}\]

where we use the same notation as in (4). Thus, we have the following optimization problem:

\[\boldsymbol{\theta}^{*} =\arg\min_{\boldsymbol{\theta}}L(\boldsymbol{\theta}),\] (6) s.t. \[\mathbf{x}_{i} =f(\mathbf{x}_{i-1},\mathbf{u}_{i},\boldsymbol{\eta}_{i})\] \[\mathbf{y}_{i} =g(\mathbf{x}_{i},\boldsymbol{\zeta}_{i}).\]

Additionally to the MSE-like loss function, we evaluate the resulting model with the Final State Error (FSE) loss function, which reads as

\[\mathrm{FSE}=\|\mathbf{c}_{N}-\mathbf{c}_{N}^{*}\|_{2}, \tag{7}\]

where \([\mathbf{c}_{N}^{*},\alpha_{N}^{*}]=\mathbf{x}_{N}^{*}\), \([\mathbf{c}_{N},\alpha_{N}]=h_{\boldsymbol{\theta}}(\mathbf{x}_{N},\mathbf{y }_{N})\) and \(t_{N}\) is a last-time moment in the considered period. Although the FSE loss function is widely used in previous studies [3, 27], it may overestimate the filter performance due to the uncertainty in the filtering process. The final coordinates may be filtered very accurately by accident while filtering the previous coordinates may be quite poor. Thus, we focus on the \(\mathrm{MSE}_{c}\) loss function as the main indicator of the filter performance.

The key ingredient of this approach is the selection of the proper parametric model \(h_{\boldsymbol{\theta}}\). Following [3] we modify the GRU model such that it solves the object localization problem specifically. A detailed description of our modification is presented in the next section.

## 3 Particle filter

One of the most efficient non-parametric approaches to solving the localization problem is the particle filter. This filter considers artificially generated particles with states \(\mathbf{p}_{i}^{(k)}\in\mathbb{R}^{d}\) at the \(i\)-th time step and the corresponding weights \(w_{i}^{k}\geq 0,\sum_{k=1}^{K}w_{i}^{k}=1\) such that the estimate of the object state at the \(i\)-th time step is computed as follows

\[\tilde{\mathbf{x}}_{i}=\sum_{k=1}^{K}w_{i}^{k}\mathbf{p}_{i}^{(k)},\]

where \(K\) is the number of particles. Particles' weights are updated according to the corresponding measurements and state updates based on the Bayes rule and likelihood estimation, see [28] for details. The important step in the particle filter is resampling, which corrects the updated particle weights and states to improve the accuracy of estimate \(\tilde{\mathbf{x}}_{i}\). The resampling step addresses the degeneracy issue, which means a few number of particles have non-zero weights. This phenomenon indicates the poor representation of the target object state. The purely stochastic resampling samples particles' indices from the multinomial distribution according to the updated weights and then update particle states, respectively, see (8). After resampling the resulting particle states are slightly perturbed with random noise to avoid equal particles' states.

\[\begin{split}& i_{1},\ldots,i_{K}\sim\mathrm{Multinomial}(w_{i+1}^{ 1},\ldots,w_{i+1}^{K})\\ &\mathbf{p}_{i+1}^{1},\ldots,\mathbf{p}_{i+1}^{K}\leftarrow \mathbf{p}_{i+1}^{i_{1}},\ldots,\mathbf{p}_{i+1}^{i_{K}}\\ & w_{i+1}^{k}=\frac{1}{K}.\end{split} \tag{8}\]

Since the particle filter processes sequential data through the recurrent updates of the particles and weights, the natural idea is to incorporate a similar approach in the recurrent neural network architecture. The particle filter recurrent neural network is proposed in [3] and we briefly describe it in the next section to highlight the difference with the proposed mePFRNN.
## 4 Recurrent neural networks inspired by particle filter

This section presents our RNN cell based on the particle filter idea, explicitly measured data, and beacons' positions. Since our model is a modification of the PFRNN [3] model, we briefly provide the main ingredients of this model.

PFRNN.Denote by \(K\) a number of particles that are emulated in the PFRNN model. Below we consider motion \(\mathbf{x}_{i}^{(k)}\) and measurement \(\mathbf{y}_{i}^{(k)}\) vectors corresponding to the \(k\)-th particle at the \(i\)-th time moment, so \(k=1,\ldots,K\) and \(i=1,\ldots,N\). PFRNN considers the environment as a 2D array and constructs its embedding through the following encoder subnetwork:

\[\mathrm{Conv}\rightarrow\mathrm{ReLU}\rightarrow\mathrm{Conv}\rightarrow \mathrm{ReLU}\rightarrow\mathrm{Conv}\rightarrow\mathrm{ReLU}\rightarrow \mathrm{Flatten}\rightarrow\mathrm{Linear}\rightarrow\mathrm{ReLU}, \tag{9}\]

where \(\mathrm{Conv}\) is a convolution layer, \(\mathrm{ReLU}\) denotes element-wise ReLU non-linearity, \(\mathrm{Linear}\) denotes a linear layer and \(\mathrm{Flatten}\) denotes a vectorization operation that reshapes the input tensor to a vector. The output of this subnetwork is the environment embedding vector \(\mathbf{e}_{env}\). At the same time, the embeddings for observations \(\mathbf{y}_{i}^{(k)}\) and motions \(\mathbf{x}_{i}^{(k)}\) are constructed via two linear layers and followed by ReLU activations and denoted by \(\mathbf{n}_{i}^{(k)}\) and \(\mathbf{m}_{i}^{(k)}\), respectively. Note that the dimensions of \(\mathbf{n}_{i}^{(k)}\) and \(\mathbf{m}_{i}^{(k)}\) are the same. Then, one transforms the environment embedding \(\mathbf{e}_{env}\) to adjusted embeddings \(\hat{\mathbf{n}}_{i}^{(k)}\) and \(\hat{\mathbf{m}}_{i}^{(k)}\) via two linear layers and followed ReLU activations. Now, the dimensions of \(\hat{\mathbf{n}}_{i}^{(k)}\), \(\hat{\mathbf{m}}_{i}^{(k)}\), \(\mathbf{n}_{i}^{(k)}\) and \(\mathbf{m}_{i}^{(k)}\) are the same. Finally, the input to the PFRNN cell described below (see (11)) is a set of vectors \(\mathbf{v}_{i}^{(k)}\) composed by concatenation of vectors \(\hat{\mathbf{n}}_{i}^{(k)}\odot\mathbf{n}_{i}^{(k)}\) and \(\hat{\mathbf{m}}_{i}^{(k)}\odot\mathbf{m}_{i}^{(k)}\), where \(\odot\) denotes element-wise product.

The baseline PFRNN cell is presented in both a graphical way (see Figure 1) and an analytical way (see equation (11)) for the reader's convenience. We note that this cell includes a reparametrization trick and updates not only the hidden states for every particle \(\mathbf{h}_{i}^{(k)}\) but also the corresponding weights \(w_{i}^{(k)}\) that are used in the resampling step. These weights typically correspond to the probability of the particle being equal to the ground-truth object state. However, in our experiment such weights are the logarithm of the corresponding probabilities, therefore the normalization step after update has the given form (see the last line in (11). After that, we adjust the resampling step to deal with the logarithms of the weights properly, see the paragraph below.

Resampling procedure.After the inference stage in the considered RNN cells, one has to make resampling, to mitigate the potential degeneracy problem. There are different approaches to performing resampling [29, 30]. The main requirement for the resampling procedure in the parametric model is to be differentiable. Therefore, the stochastic resampling (8) is not directly fitted to the considered model. Instead, the Soft Resampling procedure [3] was proposed as a trade-off between the accuracy and the related costs. This approach to resampling considers a mixture of the distribution induced by weights and the uniform distribution with probabilities \(1/K\). Therefore, the formula for updating weights and hidden states reads as follows.

\[\begin{split}& i_{1},\ldots,i_{K}\sim\mathrm{Multinomial}(\alpha w_{i+ 1}^{1}+(1-\alpha)/K,\ldots,\alpha w_{i+1}^{K}+(1-\alpha)/K)\\ &\mathbf{h}_{i+1}^{1},\ldots,\mathbf{h}_{i+1}^{K}\leftarrow \mathbf{h}_{i+1}^{i_{1}},\ldots,\mathbf{h}_{i+1}^{i_{K}}\\ & w_{i+1}^{k}\leftarrow\frac{w_{i+1}^{i_{k}}}{\alpha w_{i+1}^{i_{ k}}+(1-\alpha)/K},\end{split} \tag{10}\]

where \(\alpha>0\) to make the operation differentiable. Note that similar to the stochastic resampling, the updated hidden states \(\mathbf{h}_{i}^{k}\) are slightly perturbed. Section 5 provides more details on the usage of soft resampling in our experiments.
mePFRNN.Since PFRNN encodes the environment with the convolution operation, it requires training a number of parameters proportional to the environment size. To reduce the number of trainable parameters, we do not use the data about an environment as input to our model since such data, like beacons' and obstacles' positions, have to be implicitly extracted in the training stage. We expect such behavior of the considered mePFRNN since the environment is the external factor to the localization problem and stays the same over the particular trajectory. The motion and measurement vectors corresponding to every particle are embedded into a high dimensional space via linear layer and ReLU non-linearity. Then, the obtained embeddings are concatenated and processed by a linear layer with LeakyReLU non-linearity. The result of the latter operation is motion embedding \(\mathbf{e}_{\mathbf{u}}^{(k)}\) for every particle, which is additional input to the proposed mePFRNN cell. The encoding procedure described above is summarized in scheme (12).

\[\mathbf{x}_{i}^{(k)}\rightarrow\mathrm{Linear}\rightarrow\mathrm{ ReLU}\searrow \tag{12}\] \[\mathbf{y}_{i}^{(k)}\rightarrow\mathrm{Linear}\rightarrow\mathrm{ ReLU}\nearrow\]

Thus, mePFRNN is a voxel-independent model that can be easily used in very large environments without increasing the number of trainable parameters. One more benefit of the proposed approach becomes crucial if the beacons in the environment are located not in the middle of the artificially generated voxels in the PFRNN model. These voxels compose a grid for the considered environment to identify the beacons and obstacles with convolution encoding. In this case, the convolution operation does not adequately encode the beacons' positions and makes further filtering more noisy. The resulting cell is shown in Figure 2 graphically and in equations (13) analytically, where \(MLP\) consists of two sequential linear layers and intermediate \(\mathrm{LeakyReLU}\) nonlinearity. Note that, the Soft Resampling procedure is also used here similar to the PFRNN model described above.

\[\mathbf{e}_{i}^{(k)}= [\mathbf{e}_{\mathbf{u}}^{(k)},\mathbf{y}_{i}^{(k)}] \tag{13}\] \[\mathbf{z}_{i}^{(k)}= \sigma(\mathbf{W}_{z}[\mathbf{h}_{i-1}^{(k)},\mathbf{e}_{i}^{(k)}]+ \mathbf{b}_{z})\] \[\mathbf{r}_{i}^{(k)}= \sigma(\mathbf{W}_{r}[\mathbf{h}_{i-1}^{(k)},\mathbf{e}_{i}^{(k)}]+ \mathbf{b}_{r})\] \[\mathbf{\mu}_{i}^{(k)}= \mathbf{W}_{\mathbf{\mu}}[\mathbf{r}_{i}^{(k)}\odot\mathbf{h}_{i-1}^{(k)},\mathbf{e}_{i}^{(k)}]+\mathbf{b}_{\mathbf{\mu}}\] \[\mathbf{\Sigma}_{i}^{(k)}= \mathbf{W}_{\mathbf{\Sigma}}[\mathbf{r}_{i}^{(k)}\odot\mathbf{h}_{i-1}^{(k) },\mathbf{e}_{i}^{(k)}]+\mathbf{b}_{\mathbf{\Sigma}}\] \[\epsilon\sim \mathcal{N}(0,\mathbf{I})\] \[\mathbf{h}_{i}^{(k)}= \mathrm{LeakyReLU(BN}(\mathbf{\mu}_{i}^{(k)}+\mathbf{\Sigma}_{i}^{(k)} \odot\epsilon))\] \[\mathbf{h}_{i}^{(k)}= (1-\mathbf{z}_{i}^{(k)})\odot\mathbf{d}_{i}^{(k)}+\mathbf{z}_{i}^ {(k)}\odot\mathbf{h}_{i-1}^{(k)}\] \[\mathbf{p}_{i}^{(k)}= \mathbf{W}_{w}[\mathbf{o}_{i},\mathbf{h}_{i}^{(k)}]+b_{w}\] \[w_{i}^{(k)}= \mathbf{p}_{i}^{(k)}+w_{i-1}^{(k)}-\] \[-LogSumExp(\mathbf{p}_{i}^{(k)}+w_{i-1}^{(k)})\]

Figure 1: Baseline PFRNN cell design, where \(\mathbf{a},\mathbf{o},\mathbf{z},\mathbf{c}\) denote the linear layers that are used in computing the corresponding intermediate embeddings. For simplicity, we skip the superscript \(k\) that indicates the particle index. This cell updates both particle hidden states and weights. Denote element-wise addition and multiplication by \(+\) and \(\odot\).

Figure 2: The proposed mePFRNN cell. Square block means elementwise square of the input. MLP consists of two sequential linear layers and LeakyReLU intermediate nonlinearity. Other notation is similar to the PFRNN.
Alternative GRU-based models.In addition to the proposed mePFRNN model, we also propose two approaches to exploiting the classical GRU model (see Figure 3 and equations (14)) in the object localization problem. Namely, the EnsembleGRU model consists of many small GRU cells whose predictions are averaged to estimate the target object state. The number of models in the ensemble and the number of trained parameters in every model are selected such that the total number of the trained parameters is approximately equal to # parameters in PFRNN times # particles. The complementary approach is just to use the single GRU cell, where the number of trained parameters is equal to # particles times # parameters in PFRNN. Both approaches are complementary to the PFRNN and mePFRNN models since they do not exploit particles. Also, note that the input to the GRU cell in EnsembleGRU and HeavyGRU models is the same as the input to the PFRNN cell.

## 5 Computational experiment

In this section, we demonstrate the performance of our model and compare it with alternative neural networks and non-parametric models. For training the compared neural networks we use RMSProp optimizer [31] since it shows more stable convergence compared to Adam [32] and SGD with momentum [33], learning rate equal to \(5\cdot 10^{-4}\) and every batch consists of 150 trajectories. The maximum number of epochs is 5000 for the considered environments. During the training stage, a validation set of trajectories is used to identify the overfitting. Therefore, different environments require a different number of epochs before overfitting occurs. In particular, overfitting does not occur after 5000 epochs in the world \(10\times 10\). At the same time, overfitting is observed after 600 and 200 epochs in the World \(18\times 18\) and WORLD \(27\times 27\), respectively.

Trajectories generation procedure.To evaluate the considered methods and demonstrate the performance of the proposed mePFRNN, we consider four environments, see Figure 4. Environments world \(10\times 10\), World \(18\times 18\), and WORLD \(27\times 27\) are symmetric and therefore challenging for object localization since symmetric parts can be confused by a filtering method. Environment _Labyrinth_ is not symmetric and medium challenging for filtering methods. Thus, the considered filtering methods are compared comprehensively due to the diversity in the testing environments.

To train the parametric models we need to generate a set of trajectories \(\{\mathbf{x}_{i}^{\star}\}_{i=1}^{N}\). Since our tests assume that the object's initial state is unknown, we set the initial state \(\mathbf{x}_{0}^{\star}\) randomly for all generated trajectories. Initial states do not intersect with obstacles. Then, every next iteration updates the object state according to the motion equation, where external velocity \(u\in[0,0.2]\) is known and the direction is preserved from the previous step within the noise. In the case of a collision with an obstacle, the object's direction is changed randomly such that the next state does not indicate the collision. To simulate engine noise, the velocity \(u\) is perturbed by \(\eta_{r}\sim\mathcal{U}[-0.02,0.02]\). To simulate uncertainty in the object control system, the direction \(\phi\) is also perturbed by \(\eta_{\phi}\sim 2\pi\alpha\), where \(\alpha\sim\mathcal{U}[-0.01,0.01]\). The measurements \(\mathbf{y}_{i}\) are the distances to the five nearest beacons, which are also noisy with the noise distributed as \(\zeta\sim\mathcal{U}[-0.1,0.1]\). In the considered environments, we set the number of time steps in every trajectory \(N=100\).

To train the considered parametric models, we generate 8000 trajectories, 1000 trajectories for validation, and an additional 10000 trajectories for the testing stage. During the training process, the MSE loss is computed for the validation trajectories and if the obtained value is smaller than the current best one, then the best model is updated. This scheme helps to store the best model during the training and avoid overfitting.

Figure 3: Standard GRU cell, where \(\mathbf{z}\) and \(\mathbf{r}\) denote the linear layers to compute \(\mathbf{z}_{i}\) and \(\mathbf{r}_{i}\), Lin denotes linear layers to compute \(\hat{\mathbf{h}}_{i}\), see (14).
The list of compared models.We compare the proposed mePFRNN model with the following competitors combined in two groups. The first group consists of alternative recurrent neural networks that can solve the object localization problem, in particular the baseline PFRNN model from [3], HeavyGRU, and EnsembleGRU models. Following the study [3] we use the \(wMSE\) loss function (4) to train alternative neural network models and use \(L\) loss function (5) to train the proposed mePFRNN model. Such a choice of training setup highlights the benefit of the proposed loss function \(L\). In both settings, we use \(\beta=0.1\).

The second group consists of the particle filter (PF) and the multiparticle Kalman filter (MKF). We include these methods in the experiments to compare the performance of the parametric and non-parametric models. The performance is measured in terms of MSE\({}_{c}\), FSE, number of trained parameters, training time, and inference time. Note that, non-parametric models do not require training, therefore they are more lightweight. However, to get high accuracy a lot of particles are needed which leads to long runtime. Thus, for adequate comparison with neural methods, the classical filters were used with fewer particles to show a similar runtime as neural network-based models in the inference mode. In addition, we use stochastic resampling in the non-parametric models and Soft Resampling in the parametric ones. However, the Soft Resampling procedure for the non-parametric models does not significantly change the final performance. The comparison of the aforementioned models is presented in the next paragraph.

Discussion of the results.In experiment evaluation, we compare non-parametric and parametric models with the four test environments described above. The obtained results are summarised in Table 1. Also, we track the number of trained parameters, the amount of memory that is necessary to store them, and the runtime to update the object state in one step. From this table follows that the proposed mePFRNN model gives the best or the second-best MSE\({}_{c}\) score for the considered environments. At the same time, the FSE score is typically smaller for HeavyGRU or EnsembleGRU in the considered environments. One more important factor is the number of trainable parameters. The smaller the number of parameters, the easier embedding the model in hardware. The mePFRNN model requires fewer trainable parameters compared with other parametric models, i.e. PFRNN, HeavyGRU, and EnsembleGRU. The last but not least feature of the considered models is the inference time, i.e. the runtime to update the object state from the \(i\)-th to the \((i+1)\)-th time step. mePFRNN is slightly faster than PFRNN, and HeavyGRU appears the fastest model in the inference stage. Thus, we can conclude that the proposed mePFRNN model provides a reasonable trade-off between MSE\({}_{c}\) score, number of trainable parameters, and inference time among the considered parametric and non-parametric models tested in the selected benchmark environments.

Figure 4: Visualization of test environments. Black crosses denote beacons, and grey blocks denote obstacles. The upper row represents the very symmetric environments that are especially challenging for solving the localization problem. The _Labyrinth_ environment is not symmetric and is similar to the environment, which was used for the evaluation of filtering methods in [27].
The number of particles chosen in Table 2 is such that the inference runtime is close to the inference runtime of the considered neural networks. Since in Table 1 we fix the particular number of particles in non-parametric models, we present the MSE\({}_{c}\) and FSE losses for the larger number of particles in Table 2. It shows that if the number of particles is sufficiently large, both MSE\({}_{c}\) and FSE values are smaller than the corresponding values for parametric models. However, such an accurate estimation of states requires a much slower inference runtime compared to the considered parametric models. Thus, the neural network-based filters are of significant interest since they can show better accuracy compared to non-parametric models and provide faster updates of the object's state.

## 6 Conclusion

We present the novel recurrent neural network architecture mePFRNN to solve the object localization problem. It combines the standard GRU RNN, particle filter, and explicit measurements of distances from the object to the beacons. The latter feature makes the proposed model memory-efficient since the number of trainable parameters does not depend on the environment size. We compare the proposed mePFRNN model with the general-purpose PFRNN model and two modifications of standard GRU RNN. The test environments consist of symmetric environments of different sizes and the non-symmetric _Labyrinth_ environment. Such diversity of the test environments leads to the comprehensive comparison of the considered parametric models to solve the object localization problem. The mePFRNN model is simultaneously slightly faster in inference than the baseline PFRNN and filters the object's coordinates more precisely in the considered symmetric environments along the trajectory. Moreover, mePFRNN does not exploit explicit data about the environment or the corresponding embeddings. At the same time, the proposed mePFRNN model outperforms competitors in MSE values for the most of considered test environments.
