Mercurial > pylearn
changeset 1331:0541e7d6e916
merge
author | gdesjardins |
---|---|
date | Thu, 14 Oct 2010 23:55:55 -0400 |
parents | 3efd0effb2a7 (diff) 63fe96ede21d (current diff) |
children | 837768915081 |
files | |
diffstat | 2 files changed, 55 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pylearn/datasets/caltech.py Thu Oct 14 23:55:55 2010 -0400 @@ -0,0 +1,46 @@ +""" +Various routines to load/access MNIST data. +""" + +import os +import numpy + +from pylearn.io.pmat import PMat +from pylearn.datasets.config import data_root # config +from pylearn.datasets.dataset import Dataset + +def caltech_silhouette(): + + rval = Dataset() + + + path = os.path.join(data_root(), 'caltech_silhouettes') + + rval.train = Dataset.Obj(x=numpy.load(os.path.join(path,'train_data.npy')), + y=numpy.load(os.path.join(path,'train_labels.npy'))) + rval.valid = Dataset.Obj(x=numpy.load(os.path.join(path,'val_data.npy')), + y=numpy.load(os.path.join(path,'val_labels.npy'))) + rval.test = Dataset.Obj(x=numpy.load(os.path.join(path,'test_data.npy')), + y=numpy.load(os.path.join(path,'test_labels.npy'))) + + rval.n_classes = 101 + rval.img_shape = (28,28) + + return rval + +def caltech_silhouette2(): + + rval = Dataset() + + from scipy import io + path = '/data/lisa6/desjagui/caltech101_silhouettes_28_split1.mat' + + data = io.loadmat(open(path,'r')) + + rval.train = Dataset.Obj(x=data['train_data'], y=data['train_labels']) + rval.valid = Dataset.Obj(x=data['val_data'], y=data['val_labels']) + rval.test = Dataset.Obj(x=data['test_data'], y=data['test_labels']) + rval.n_classes = 101 + rval.img_shape = (28,28) + + return rval
--- a/pylearn/datasets/test_modes.py Thu Oct 14 13:33:33 2010 -0400 +++ b/pylearn/datasets/test_modes.py Thu Oct 14 23:55:55 2010 -0400 @@ -99,7 +99,8 @@ def __init__(self, n_modes, img_shape, seed=238904, min_p=1e-4, max_p=1e-1, - min_w=0., max_w=1.): + min_w=0., max_w=1., + w = None, p = None): self.n_modes = n_modes self.img_shape = img_shape @@ -107,9 +108,14 @@ self.img_size = numpy.prod(img_shape) # generate random p, w values - self.p = min_p + self.rng.rand(n_modes) * (max_p - min_p) - w = min_w + self.rng.rand(n_modes) * (max_w - min_w) + if p is None: + p = min_p + self.rng.rand(n_modes) * (max_p - min_p) + self.p = p + + if w is None: + w = min_w + self.rng.rand(n_modes) * (max_w - min_w) self.w = w / numpy.sum(w) + self.sort_w_idx = numpy.argsort(self.w) self.modes = self.rng.randint(0,2,size=(n_modes,self.img_size))