From c822caa3b8396060e93104d0cf4c6a4404db19eb Mon Sep 17 00:00:00 2001 From: Pascal Lamblin Date: Thu, 7 May 2015 20:38:10 -0400 Subject: [PATCH 1/7] Attempt at fixing doc generation --- doc/conf.py | 2 ++ pylearn2/datasets/hdf5.py | 28 ++++++++++++++-------------- pylearn2/training_algorithms/sgd.py | 28 +++++++++++++++------------- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index d702df15f4..169bec2a9f 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -17,6 +17,8 @@ # is relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. #sys.path.append(os.path.abspath('some/directory')) +pylearn2_path = os.path.join(os.path.dirname(__file__), os.pardir) +sys.path.append(os.path.abspath(pylearn2_path)) # General configuration # --------------------- diff --git a/pylearn2/datasets/hdf5.py b/pylearn2/datasets/hdf5.py index 7b586390d9..d2b0c17f52 100644 --- a/pylearn2/datasets/hdf5.py +++ b/pylearn2/datasets/hdf5.py @@ -277,15 +277,15 @@ def get(self, sources, indexes): """ Retrieves the requested elements from the dataset. - Parameter - --------- + Parameters + ---------- sources : tuple A tuple of source identifiers indexes : slice or list A slice or a list of indexes - Return - ------ + Returns + ------- rval : tuple A tuple of batches, one for each source """ @@ -329,8 +329,8 @@ def get_num_examples(self, source_or_alias=None): returing a list of num_examples. Do not rely on this function unless unavoidable. - Parameter - --------- + Parameters + ---------- source_or_alias : str, optional The source you want the number of examples of """ @@ -363,8 +363,8 @@ def __getitem__(self, key_or_alias): """ Returns the item corresponding to a key or an alias. - Parameter - --------- + Parameters + ---------- key_or_alias: any valid key for a dictionary A key or an alias. """ @@ -379,8 +379,8 @@ def __setitem__(self, keys, value): """ Add an element to the dictionary - Parameter - --------- + Parameters + ---------- keys: either a tuple `(key, alias)` or any valid key for a dictionary The key and optionally the alias of the new element. value: any input accepted as value by a dictionary @@ -419,8 +419,8 @@ def set_alias(self, key, alias): Add an alias to a key of the dictionary that doesn't have already an alias. - Parameter - --------- + Parameters + ---------- keys: any valid key for a dictionary A key of the dictionary. alias: any input accepted as key by a dictionary @@ -446,8 +446,8 @@ def __contains__(self, key_or_alias): """ Returns true if the key or alias is an element of the dictionary - Parameter - --------- + Parameters + ---------- keys_or_alias: any valid key for a dictionary The key or the alias to look for. """ diff --git a/pylearn2/training_algorithms/sgd.py b/pylearn2/training_algorithms/sgd.py index 495a0fd9ab..41c7acf9c8 100644 --- a/pylearn2/training_algorithms/sgd.py +++ b/pylearn2/training_algorithms/sgd.py @@ -898,19 +898,21 @@ class EpochMonitor(object): monitor_rate : int (optional) Call full monitor updates within epochs every `monitor_rate` batches - YAML usage - ---------- - model: &model !obj:pylearn2.models.mlp.MLP { - ... - }, - algorithm: !obj:pylearn2.training_algorithms.sgd.SGD { - update_callbacks: [ - !obj:pylearn2.training_algorithms.sgd.EpochMonitor { - model: *model, - tick_rate: 20, - monitor_rate: 110 }], - ... - } + Example + ------- + YAML usage:: + + model: &model !obj:pylearn2.models.mlp.MLP { + ... + }, + algorithm: !obj:pylearn2.training_algorithms.sgd.SGD { + update_callbacks: [ + !obj:pylearn2.training_algorithms.sgd.EpochMonitor { + model: *model, + tick_rate: 20, + monitor_rate: 110 }], + ... + } """ def __init__(self, model, tick_rate=None, monitor_rate=None): self.model = model From fab33f04d2464413eac68d06a3dac5e83f3e0357 Mon Sep 17 00:00:00 2001 From: Pascal Lamblin Date: Fri, 8 May 2015 21:27:51 -0400 Subject: [PATCH 2/7] New try --- pylearn2/training_algorithms/sgd.py | 4 ++-- setup.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pylearn2/training_algorithms/sgd.py b/pylearn2/training_algorithms/sgd.py index 41c7acf9c8..321e1b4f01 100644 --- a/pylearn2/training_algorithms/sgd.py +++ b/pylearn2/training_algorithms/sgd.py @@ -898,8 +898,8 @@ class EpochMonitor(object): monitor_rate : int (optional) Call full monitor updates within epochs every `monitor_rate` batches - Example - ------- + Examples + -------- YAML usage:: model: &model !obj:pylearn2.models.mlp.MLP { diff --git a/setup.py b/setup.py index 831864bb8d..2d51d97972 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,16 @@ from __future__ import print_function +import sys import warnings from setuptools import setup, find_packages, Extension from setuptools.command.install import install import numpy -from theano.compat.six.moves import input +# Importing theano.compat.six.moves.input may not work here, +# because the dependencies may not have been installed yet. +PY3 = sys.version_info[0] == 3 +if not PY3: + input = raw_input # Because many people neglected to run the pylearn2/utils/setup.py script # separately, we compile the necessary Cython extensions here but because From fdb3da3aec1ef994f27aedb20328e6436c7f0990 Mon Sep 17 00:00:00 2001 From: Pascal Lamblin Date: Mon, 11 May 2015 18:17:21 -0400 Subject: [PATCH 3/7] Fixes to the script itself --- doc/scripts/docgen.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/scripts/docgen.py b/doc/scripts/docgen.py index 4a1aa32d3c..07f98f15f1 100644 --- a/doc/scripts/docgen.py +++ b/doc/scripts/docgen.py @@ -11,7 +11,9 @@ if __name__ == '__main__': - throot = "/".join(sys.path[0].split("/")[:-2]) + # Equivalent of sys.path[0]/../.. + throot = os.path.abspath( + os.path.join(sys.path[0], os.pardir, os.pardir)) options = defaultdict(bool) options.update(dict([x, y or True] for x, y in getopt.getopt(sys.argv[1:], 'o:', ['epydoc', 'rst', 'help', 'nopdf', 'test'])[0])) @@ -45,19 +47,19 @@ def mkdir(path): if options['--test']: import sphinx sys.path[0:0] = [os.path.join(throot, 'doc')] - out = sphinx.main(['', '-b' 'text', '-W', - '-E', os.path.join(throot, 'doc'), '.']) + out = sphinx.build_main(['', '-b' 'text', '-W', + '-E', os.path.join(throot, 'doc'), '.']) sys.exit(out) elif options['--all'] or options['--rst']: import sphinx sys.path[0:0] = [os.path.join(throot, 'doc')] - sphinx.main(['', '-E', os.path.join(throot, 'doc'), '.']) + sphinx.build_main(['', '-E', os.path.join(throot, 'doc'), '.']) if not options['--nopdf']: # Generate latex file in a temp directory import tempfile workdir = tempfile.mkdtemp() - sphinx.main(['', '-E', '-b', 'latex', + sphinx.build_main(['', '-E', '-b', 'latex', os.path.join(throot, 'doc'), workdir]) # Compile to PDF os.chdir(workdir) From fe881ef470251127f2259d6d0eb334a391048d41 Mon Sep 17 00:00:00 2001 From: Pascal Lamblin Date: Mon, 11 May 2015 18:17:35 -0400 Subject: [PATCH 4/7] Decrease nesting level so LaTeX does not complain --- pylearn2/gui/get_weights_report.py | 6 +++--- pylearn2/models/s3c.py | 29 ++++++++++++++--------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/pylearn2/gui/get_weights_report.py b/pylearn2/gui/get_weights_report.py index 3c162c50f4..0ca1ee6312 100755 --- a/pylearn2/gui/get_weights_report.py +++ b/pylearn2/gui/get_weights_report.py @@ -36,9 +36,9 @@ def get_weights_report(model_path=None, rescale : str A string specifying how to rescale the filter images: - 'individual' (default) : scale each filter so that it - uses as much as possible of the dynamic range - of the display under the constraint that 0 - is gray and no value gets clipped + uses as much as possible of the dynamic range + of the display under the constraint that 0 + is gray and no value gets clipped - 'global' : scale the whole ensemble of weights - 'none' : don't rescale dataset : pylearn2.datasets.dataset.Dataset diff --git a/pylearn2/models/s3c.py b/pylearn2/models/s3c.py index 5f0fcb6efe..af1d16f809 100644 --- a/pylearn2/models/s3c.py +++ b/pylearn2/models/s3c.py @@ -282,23 +282,22 @@ class S3C(Model, Block): local_rf_src : Dataset, optional if not None, it should be a dataset. it requires the following other params: - - - local_rf_shape : a 2 tuple - - One of: - - - local_rf_stride: a 2 tuple or None - if specified, pull out patches on a regular grid - - local_rf_max_shape: a 2 tuple or None - if specified, pull out patches of random shape and - location - - local_rf_draw_patches : WRITEME - if true, local receptive fields are patches from - local_rf_src. otherwise, they're random patches. - will initialize the weights to have only local - receptive fields. (won't make a sparse matrix or - anything like that) + - `local_rf_shape` : a 2 tuple + - One of `local_rf_stride`, `local_rf_max_shape`, `local_rf_draw_patches` incompatible with random_patches_src for now + local_rf_shape : a 2 tuple + local_rf_stride: a 2 tuple or None + if specified, pull out patches on a regular grid + local_rf_max_shape: a 2 tuple or None + if specified, pull out patches of random shape and + location + local_rf_draw_patches : WRITEME + if true, local receptive fields are patches from + local_rf_src. otherwise, they're random patches. + will initialize the weights to have only local + receptive fields. (won't make a sparse matrix or + anything like that) init_unit_W : bool if True, initializes weights with unit norm """ From 0798c5003cdcc925bde513e45eaccb5cbaa268b6 Mon Sep 17 00:00:00 2001 From: Pascal Lamblin Date: Mon, 11 May 2015 19:29:11 -0400 Subject: [PATCH 5/7] Try to bypass numpy installation --- .requirements.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.requirements.txt b/.requirements.txt index 5e5cb3f03a..2ece3f4ce6 100644 --- a/.requirements.txt +++ b/.requirements.txt @@ -1,4 +1,7 @@ # This is for readthedocs.org to be able to build the documentation, # ignore otherwise numpydoc -git+git://github.com/Theano/Theano.git + +--allow-external theano +--allow-unverified theano +git+https://github.com/Theano/Theano.git#egg=theano From c46c3037470d6737d59e4bab99016552d412fa76 Mon Sep 17 00:00:00 2001 From: Pascal Lamblin Date: Tue, 12 May 2015 10:29:02 -0400 Subject: [PATCH 6/7] Try to explicitly specify numpy and scipy --- .requirements.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.requirements.txt b/.requirements.txt index 2ece3f4ce6..66d87d2f91 100644 --- a/.requirements.txt +++ b/.requirements.txt @@ -2,6 +2,12 @@ # ignore otherwise numpydoc +#--allow-external numpy +numpy>=1.6.2 + +#--allow-external scipy +scipy>=0.11 + --allow-external theano --allow-unverified theano git+https://github.com/Theano/Theano.git#egg=theano From e6e5640dc6fd4d8192a43aae36bda0cb038b7aca Mon Sep 17 00:00:00 2001 From: Pascal Lamblin Date: Tue, 12 May 2015 14:15:11 -0400 Subject: [PATCH 7/7] Remove unneeded commented-out lines --- .requirements.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.requirements.txt b/.requirements.txt index 66d87d2f91..699a182cc7 100644 --- a/.requirements.txt +++ b/.requirements.txt @@ -1,11 +1,7 @@ # This is for readthedocs.org to be able to build the documentation, # ignore otherwise numpydoc - -#--allow-external numpy numpy>=1.6.2 - -#--allow-external scipy scipy>=0.11 --allow-external theano