August 16, 2013

Finished debugging changes to `corr_to_likelihood`

.

Recap: since projected model curves are discretely sampled at coarse intervals, multiple observed points may correspond to the same model point. The results below show this. The projected model curve is sampled every 2 pixels (`index_delta_2d`

), so each model point has between 2 and 3 corresponding data points.

The new scheme post-processes the indexes by linearly interpolating the model curve and projecting the data point onto the neighboring line segments. Resulting indices are much improved:

Note that viewing angle distorts the correspondence angles somewhat. Non-perpendicular correspondence lines may be simply due to non-orthogonal viewing direction.

Since coarse sampling is no longer an issue, we can increase the 2D sample period and still get good results. Below is the result after increasing 2D sampling period from 2 to 5:

This has implications on training results. Re-running training using `exp_2013_08_11_train_all`

:

*No Perturb Model*

```
smoothing_variance: 0.0030
noise_variance: 1.0805
position_variance: 1.6270e+04
rate_variance: 0.2904
perturb_smoothing_variance: 1
perturb_rate_variance: 1
perturb_position_variance: 1
perturb_scale: 2.5000
Final ML: -9.094636e+03
```

*Ind-Perturb Model*

```
smoothing_variance: 0.0034
noise_variance: 0.3472
position_variance: 1.6458e+04
rate_variance: 0.2605
perturb_smoothing_variance: 1.4186e-06
perturb_rate_variance: 3.0555e-04
perturb_position_variance: 0.5467
perturb_scale: 2.5000
Final ML: -6.203953e+03
```

*OU-Perturb Model*

```
smoothing_variance: 0.0035
noise_variance: 0.3486
position_variance: 1.6440e+04
rate_variance: 0.2587
perturb_smoothing_variance: 1.4874e-06
perturb_rate_variance: 3.6269e-04
perturb_position_variance: 0.7241
perturb_scale: 2.3364
Final ML: -6.156721e+03
```

*SqExp-Perurb Model*

```
smoothing_variance: 0.0035
noise_variance: 0.3479
position_variance: 1.6246e+04
rate_variance: 0.2745
perturb_smoothing_variance: 1.5495e-06
perturb_rate_variance: 4.1614e-04
perturb_position_variance: 0.6613
perturb_scale: 0.9654
Final ML: -6.159716e+03
```

**Awesome news: perturb smoothing variance is now non-negligible!** There must have been so much IID noise resulting from bad indexing that it totally masked the perturb smoothing variance.

The totally validates our efforts to fix indexing. Before, the model was fundamentally broken; bad indexing was preventing us from making any correct inferences beyond a certain level of granularity. By fixing indexing, we're suddenly able to everything clearly, whereas before we were squinting through a noisy haze.

**Other observations**

- ML is much lower compared to the badly indexed results, which were one the order of -8000 (according to this post).
- Noise variance dropped from 0.68 to 0.35.
- Smoothing variance has increased, probably because we attribute fewer deviations to IID noise. Great!
- Global rate variance is lower, while perturb rate variance roughly tripled.
- Perturb scale dropped slightly. Since noise variance can't explain independent deviations, the perturb-model takes over, becomes closer to independent.

Lets see if anything interesting comes out of our reconstructions...

*OU-perturb Model*

```
az = 24;
el = 16;
axis_ = [ 70.0000 110.0000 50.0000 110.0000 47.8040 224.0467 ]
exp_2013_08_11_reconstruct_for_web(test_Corrs_ll_2, retraining_results{3}, 3, axis_, el, az, num_views, '/Users/ksimek/src/research_blog/img/2013-08-16-ou-model-%d.png', '/ksimek/research/img/2013-08-16-ou-model-%d.png', 'ou-reconstruct-anim', true)
```

*SqExp-Perturb Model*

We can remove perturbations that arise from poor camera calibration by assuming it is captured in the linear and offset perturbations; under this assumption, the remaining cubic-spline smooth perturbations capture the true plant motion.

Removing linear and offset perturbations is as simple as removing their contributions to \(K^*\) in yesterday's equation for the mean of the predictive distribution.

Command:

```
reverse = false(1,num_tracks);
reverse([1 2 4 5 6 8 9 10 11 12 14 15]) = true;
% error above, should omit 11:
% reverse([1 2 4 5 6 8 9 10 12 14 15]) = true;
exp_2013_08_16_visualize_smooth_perturbations( ...
test_Corrs_ll_2, ...
retraining_results{3}, ...
3, axis_, el, az, num_views, ...
'/Users/ksimek/src/research_blog/img/2013-08-16-ou-model-smooth-%d.png', ...
'/ksimek/research/img/2013-08-16-ou-model-smooth-%d.png', ...
'ou-reconstruct-smooth-anim', reverse)
```

Results:

It's notable that the little curves at the top don't move. Attaching them to the large main step will allow them to move, which should improve ML.

It should also significantly affect training if we train with attachments in place. Perturb_position_variance should be responsible for less of the variance, and perturb_smoothing_variance should explain more.

Tasks:

- Create new attachments structure. Indicates which curve and index the curve is attached to.
- Algorithm to convert N attachment to M track-sets, where M is the number of connected components in the attachment structure. (in practice, attachment structure might be irrelevant, given the track-set structure).
- New function to construct prior matrix for track-sets, as opposed to individual tracks.
- New function to evaluate ML over track-sets.

- Add attachments before training.
- Complete end-to-end training
- input: path of training and curves
- automatically add attachments
- automatically reverse curves as needed
- save trained parameters somewhere

Saturday Thoughts - Enabling Non-gaussian models by using Gaussian models as proposal distributions →
← Index Refinement; Mean-curve Reconstruction