lisa-lab/pylearn2 — pull request #1096 by madisonmay (2014-08-26 07:30:05+00:00)
Title: Fix for init_bias_target_marginals bug

Resolves issue #1083 caused by deprecation of one-hot encoding format.

As always, comments and suggestions welcome. It doesn't make sense to use this parameter for examples with multiple labels, so I'm checking for the presence of multiple labels by ensuring that there is a single dimension that is not `1` in the shape of `y` and raising an AssertionError if that does not hold.

```
if np.max(y.shape) != np.prod(y.shape):
raise AssertionError("Each example must have a "
"single label.")
```

The simplest way to check for multiple labels would be to assert that `y.shape[1] == 1`, but since I'm not 100% sure that labels will always take that format I'm checking to make sure that the max and the product are equal in order to preserve generality. If this is overkill (or if the inputs should always be of shape `(n_rows, 1)`), I'll gladly revert to the simpler assertion.

Sorry for the bit of noise due to some PEP8 fixes and auto-trimming of trailing whitespace.