scikit-learn/scikit-learn — pull request #2545 by jfelectron (2013-10-23 01:52:03+00:00)
Title: Fix for out of bounds error in RBM  with odd # of rows

Fixes out of bounds error in RBM with odd numbered matrix rows due to
gen_even_slices generating even slices that overshoot bounds of matrix.

/usr/local/lib/python2.7/dist-packages/sklearn/neural_network/rbm.pyc
in fit(self, X, y)
310
311 for batch_slice in batch_slices:
--> 312 pl_batch = self._fit(X[batch_slice], rng)
313
314 if verbose:

/usr/lib/python2.7/dist-packages/scipy/sparse/csr.pyc in
__getitem__(self, key)
279
280 elif isintlike(key) or isinstance(key,slice):
--> 281 return self[key,:]
#[i] or [1:2]
282 else:
283 return self[asindices(key),:]
#[[1,2]]

/usr/lib/python2.7/dist-packages/scipy/sparse/csr.pyc in
__getitem__(self, key)
239 #[1:2,??]
240 if isintlike(col) or isinstance(col, slice):
--> 241 return self._get_submatrix(row, col)
#[1:2,j]
242 else:
243 P = extractor(col,self.shape[1]).T
#[1:2,[1,2]]

/usr/lib/python2.7/dist-packages/scipy/sparse/csr.pyc in
_get_submatrix(self, row_slice, col_slice)
380 i0, i1 = process_slice( row_slice, M )
381 j0, j1 = process_slice( col_slice, N )
--> 382 check_bounds( i0, i1, M )
383 check_bounds( j0, j1, N )
384

/usr/lib/python2.7/dist-packages/scipy/sparse/csr.pyc in
check_bounds(i0, i1, num)
376 raise IndexError( \
377 "index out of bounds: 0<=%d<%d, 0<=%d<%d,
%d<%d" %\
--> 378 (i0, num, i1, num, i0, i1) )
379
380 i0, i1 = process_slice( row_slice, M )

IndexError: index out of bounds: 0<=113000<113966, 0<=114000<113966,
113000<114000