lisa-lab/pylearn2 — pull request #728 by vdumoulin (2014-03-21 14:05:05+00:00)
Title: DenseDesignMatrix IndexSpace-related bug fix

In `DenseDesignMatrix`, if `y` is provided and `y.ndim !=2`, it is considered as living in `IndexSpace`. However, `IndexSpace` batches need to be 2D arrays, even if there is only one index per example. This makes datasets like `MNIST` crash when initialized with `one_hot=False` (the default) and when `MNIST.iterator` is called:

```
ValueError: The value of a IndexSpace batch must be 2D, got 1 dimensions for [7 2 1 0 4 1 4 9 5 9 0 6 9 0 1 5 9 7 3 4 9 6 6 5 4 0 7 4 0 1 3 1 3 4 7 2 7
1 2 1 1 7 4 2 3 5 1 2 4 4 6 3 5 5 6 0 4 1 9 5 7 8 9 3 7 4 6 4 3 0 7 0 2 9
1 7 3 2 9 7 7 6 2 7 8 4 7 3 6 1 3 6 9 3 1 4 1 7 6 9].
```

As a quick-fix, I propose to reshape `y` as a 2D array when it is considered as living in `IndexSpace`. I wrote a test for `MNIST` to make sure this doesn't break again.

I also took the liberty to deprecate `MNIST`'s `one_hot` parameter and am willing to deprecate other similar parameters if desired.