Mercurial > pylearn
changeset 1474:a57f4839a9d8
merge
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Wed, 18 May 2011 10:52:42 -0400 |
parents | 91a475ca9b6d (diff) c41fdf8c35b8 (current diff) |
children | e7401822d596 |
files | pylearn/gd/sgd.py |
diffstat | 4 files changed, 15 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/pylearn/dataset_ops/protocol.py Wed Apr 27 11:34:36 2011 -0400 +++ b/pylearn/dataset_ops/protocol.py Wed May 18 10:52:42 2011 -0400 @@ -3,6 +3,7 @@ """ __docformat__ = "restructuredtext_en" +import numpy import theano class Dataset(theano.Op): @@ -119,6 +120,6 @@ except: x = self.x_ = self.fn(*self.fn_args) if idx.ndim == 0: - z[0] = x[int(idx)] + z[0] = numpy.asarray(x[int(idx)]) # asarray is important for memmaps else: - z[0] = x[idx] + z[0] = numpy.asarray(x[idx]) # asarray is important for memmaps
--- a/pylearn/datasets/icml07.py Wed Apr 27 11:34:36 2011 -0400 +++ b/pylearn/datasets/icml07.py Wed May 18 10:52:42 2011 -0400 @@ -3,6 +3,7 @@ import os, sys import numpy +from config import get_filepath_in_roots from pylearn.io.amat import AMat class DatasetLoader(object): @@ -68,7 +69,9 @@ assert numpy.all(labels < self.n_classes) return inputs, labels -def icml07_loaders(new_version=True, rootdir='.'): +def icml07_loaders(new_version=True, rootdir=None): + if rootdir is None: + rootdir = get_filepath_in_roots('icml07data_twiki') rval = dict( mnist_basic=DatasetLoader( http_source='http://www.iro.umontreal.ca/~lisa/icml2007data/mnist.zip',
--- a/pylearn/gd/sgd.py Wed Apr 27 11:34:36 2011 -0400 +++ b/pylearn/gd/sgd.py Wed May 18 10:52:42 2011 -0400 @@ -1,6 +1,6 @@ """A stochastic gradient descent minimizer. """ - +import numpy import theano def sgd_updates(params, grads, stepsizes): @@ -35,11 +35,11 @@ momentum = [momentum for p in params] if len(params) != len(grads): raise ValueError('params and grads have different lens') - headings = [theano.shared(p.get_value(borrow=False)*0) for p in params] + headings = [theano.shared(numpy.zeros_like(p.get_value(borrow=True))) for p in params] updates = [] for s, p, gp, m, h in zip(stepsizes, params, grads, momentum, headings): updates.append((p, p + s * h)) - updates.append((h, m*h - (1-m)*gp)) + updates.append((h, m*h - (1.0-m)*gp)) return updates
--- a/pylearn/io/image_tiling.py Wed Apr 27 11:34:36 2011 -0400 +++ b/pylearn/io/image_tiling.py Wed May 18 10:52:42 2011 -0400 @@ -100,6 +100,10 @@ H, W = img_shape Hs, Ws = tile_spacing + out_scaling = 1 + if output_pixel_vals and str(X.dtype).startswith('float'): + out_scaling = 255 + out_array = numpy.zeros(out_shape, dtype='uint8' if output_pixel_vals else X.dtype) for tile_row in xrange(tile_shape[0]): for tile_col in xrange(tile_shape[1]): @@ -121,7 +125,7 @@ tile_row * (H+Hs):tile_row*(H+Hs)+H, tile_col * (W+Ws):tile_col*(W+Ws)+W ] \ - = this_img * (255 if output_pixel_vals else 1) + = this_img * out_scaling return out_array