Volker Strobel edited DeclareMathOperator_argmin_arg_min_DeclareMathOperator__1.tex  almost 8 years ago

Commit id: 57de5a43efc630a58864a04e93a02c147f5b7288

deletions | additions      

       

% TODO: Write some stuff about the low-level implementation  \subsection{$k$-Nearest Neighbors ($k$NN) algorithm}  % TODO: Write that one could also use a more efficient data structure than simply a list  For a given sample, the $k$-Nearest Neighbors ($k$NN) algorithm measures the similarity of this sample with all samples in the training dataset and outputs the $k$ most similar training examples. The similarity measure is a function that takes two samples as input and outputs a real value. We used the cosine similarity as similarity function, since it is bounded between 0 and 1. While other similarity measurements exists, the basic similarity measures—such as Euclidean distance—do not have a large impact on the results (Figure xxx). The choice of $k$ was based on the heuristic that XXX (TODO: write something like the sqrt of N or whatever) and on cross-validation.   While the $k$NN algorithm is one of the simplest machine learning algorithms, it  offers several advantages: it is non-parametric, allowing for the  modeling of arbitrary distributions. Its capability to output multiple  predictions with an associated confidence allows for neat integration  with the proposed particle filter. Its simplicity comes together with transparency: it allows for spotting the possible sources of error: for example, wrongly labeled training examples. While the naive approach in using $k$NN for regression calculates the mean of the $k$ outputs, we decided to use a more complex method. This motivation is visualized in Figure XXX: If $k=2$ and the output values are distant to each other, averaging them would yield a value in the middle, which is with high certainty not the correct position. Over time, however, the ambiguity, can be resolved, when both estimates of the $k$NN model fall together. Compared to the Kalman filter, which is displayed in Figure XXX, the full Bayesian filter can immediately find the correct position. Since a full Bayesian filter is computationally complex, a variant that is based on Monte Carlo sampling was used: the particle filter. A more detailed description of the filtering technique can be found in the next section.   % TODO: Compare particle filter with Kalman filter!!   It often outperforms more sophisticated algorithms. A frequent critique regarding the $k$NN is its increasing computational complexity with an increasing size of the training dataset. However, its time complexity can be reduced by storing the training examples in an efficient manner, such as a binary tree structure. However, all of our training datasets were below 1000 images, resulting in fast predictions based on a list structure.   \begin{algorithm}  \caption{{Particle filter update}}  \label{alg:particle_filter}  \begin{algorithmic}[1]  \Procedure{Particle\_Filter}{$\mathcal{X}_{t-1}, z_t^x, z_t^y, f_t^x, f_t^y$}  % q is process noise, r is measurement noise  \State $q_x^2 = 15$, $q_y^2 = 15$, $r_x^2 = 100$, $r_y^2 = 100$  \LineComment{Particle update}  \For{$m = 1$ to $M$}  \State sample $x_t^{[m]} \sim \mathcal{N}(x_{t-1}^{[m]} + f_t^x, q_x^2)$  \State sample $y_t^{[m]} \sim \mathcal{N}(y_{t-1}^{[m]} + f_t^y, q_y^2)$  \State $w_t^{[m]} \gets p(z_t^x \mid x_t^{[m]}) p(z_t^y \mid y_t^{[m]})$  % Resampling wheel  \EndFor  \LineComment{Importance resampling}  \State $\mathcal{X}_t \gets$ \Call{Resampling\_Wheel}{$\mathcal{X}_{temp}, w_t$}  \EndProcedure  \end{algorithmic}  \end{algorithm}  \begin{algorithm}  \caption{{Resampling wheel}}  \label{alg:resampling_wheel}  \begin{algorithmic}[1]  \Procedure{Resampling\_Wheel}{$\mathcal{X}_{temp}, w_t$}  \State $\mathcal{X}_t \gets \emptyset$  \State sample $idx \sim M\cdot\mathcal{U}(0, 1)$  \State $\beta \gets 0$  \State $mw = max(w_t)$  \For{$m = 1$ to $M$}  \State $\beta \gets \beta + \mathcal{U}(0, 1)\cdot 2\cdot mw$  \While{$\beta > w_t[idx]$}  \State $\beta \gets beta - w_t[idx]$  \State $idx \gets (idx + 1) \mod M$  \EndWhile  \State add $\mathcal{X}_{temp}[idx]$ to $\mathcal{X}_t$  \EndFor  \EndProcedure  \end{algorithmic}  \end{algorithm}  \begin{algorithm}  \caption{{Initialize texton framework}}  \label{alg:trexton_init}  \begin{algorithmic}[1]  \Procedure{Init\_TreXton}{}  \State $t \gets 0$   %\State textons $\gets$ \Call{csv\_read\_textons}{}  %\State ann $\gets$ \Call{load\_neural\_network}{}  \State $\mathcal{X}_0 \gets$ \Call{init\_particles}{}  \EndProcedure  \end{algorithmic}  \end{algorithm}  \begin{algorithm}  \caption{{Run texton framework}}  \label{alg:trexton_run}  \begin{algorithmic}[1]  \Procedure{Run\_TreXton}{}  \State $t \gets t+1$   \State $I_t \gets$ \Call{Receive\_Img\_from\_Webcam}{}  \State $\widetilde{I_t} \gets$ \Call{Standardize\_Image}{$I_t$}  \State $\mathcal{H}_t \gets$ \Call{Get\_Histogram}{$\widetilde{I_t}$}  \State $z_t^x, z_t^y \gets$ \Call{Predict\_Position}{$\mathcal{H}_t$}  \State $f_t^x, f_t^y \gets$ \Call{Calc\_Flow}{$I_t$}  \State $\mathcal{X}_t \gets$  \Call{Particle\_Filter}{$\mathcal{X}_{t-1}, z_t^x, z_t^y, f_t^x,  f_t^y$}  \State $x_t, y_t \gets$ \Call{Weighted\_Average}{$\mathcal{X}_t$}  \State \Call{Send\_Pos}{$x_t, y_t$}  \EndProcedure  \end{algorithmic}  \end{algorithm}