# Compression of Vehicle Trajectories with a Variational Autoencoder
## 4 Methodology
### Maneuver Classification  
In a maneuver classification task, a learning algorithm is trained to specify which maneuver from a fixed class belongs to the input trajectories. Supervised learning algorithms solve this task by producing a function mapping from the input space \(\mathcal{X}\) to a finite category class \(\mathcal{C}\), which is a subset of the natural numbers \(\mathbb{N}\). In this case, the input trajectory is a tensor of \(\mathcal{X}\equiv\mathbb{R}^{2\times 60}\) and the category set is \(\mathcal{C}=\{\)left lane changing, lane keeping, right lane changing\(\}\) and can be identified by a numeric label code \(\{0,1,2\}\) respectively. Although the CVAE is not trained as a classifier, it can cluster the data by learning its intrinsic properties, which is useful for classification as well.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**BiLSTM-AE** & \multicolumn{4}{c}{**Latent Dimension**} \\ \hline C & 10 & 12 & 15 & 20 \\ Valid & 31.2 & 21.74 & 14.81 & 9.6 \\ Training & 76.8 & 32.45 & 21.94 & 12.36 \\ Complexity & 12,522 & 17,714 & 27,182 & 47,442 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Loss values of Bidirectional LSTM AE Training.  
\begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline
**V-AE** & \multicolumn{6}{c}{**Latent Dimension**} \\ \hline C & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 \\ Valid & 12.87 & 8.78 & 6.91 & 6.27 & 6.64 & 6.02 & 5.67 & 6.11 \\ Training &  
The CVAE has learned latent information about the maneuvers in an unsupervised way, illustrated by the 3D latent space visualization in Figure 6. An arbitrary 6-second trajectory is mapped into the latent space as a Gaussian distribution by the trained CVAE encoder part. The centrum of this distribution is the expected value vector. These vectors can be visualized using a projection from the latent space to the three-dimensional space. On the three-dimensional space in Figure 6, every dot colored by the maneuver label belongs to a trajectory. According to the maneuvers, the points representing different trajectories are automatically separated in the latent space, although the labels belonging to the maneuvers haven't been used during the training. This is due to the construction of the CVAE with adequate regularizing ability, in which the prior distribution of the latent space  
Figure 5: Variational Autoencoder performance on copying the trajectory data without using the traffic information of surrounding vehicles. From top to bottom: Reconstruction with 10-, 6-, and 4-dimensional latent space. From left to right: The same trajectory of a lane-keeping and lane changing on the right and the left, respectively. The red curve is the ground truth; the green one is the most probable reconstruction trajectory. The horizontal axis is the longitudinal \(y\) coordinate of the vehicle’s trajectory, and the vertical is the lateral \(x\) coordinate. Under the trajectory graphs: The hidden state vector is plotted.  
variable is assumed to be standard normal, and the probabilistic encoder and decoder follow a normal distribution. The CVAE preprocessed the trajectories by selecting the characteristic features, making it easier to find planes that separate the classes with a small error. A Support Vector Machine [38] on context vectors can classify trajectories according to maneuvers with 88-91% accuracy (see Table 5), which is more than the tools can that have been specifically trained for maneuver detection [14].