changeset 867:aaaed35c995e

improved the initialization range for weights in lecun1998
author James Bergstra <bergstrj@iro.umontreal.ca>
date Tue, 10 Nov 2009 17:48:44 -0500
parents 9b13f7bb00ef
children c3e7ae2bdb4b
files pylearn/shared/layers/lecun1998.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/shared/layers/lecun1998.py	Tue Nov 10 17:44:36 2009 -0500
+++ b/pylearn/shared/layers/lecun1998.py	Tue Nov 10 17:48:44 2009 -0500
@@ -96,8 +96,12 @@
         w_shp = (n_filters, n_imgs) + filter_shape
         b_shp = (n_filters,)
 
-        w = shared(numpy.asarray(rng.uniform(low=-.05, high=.05, size=w_shp), dtype=dtype))
-        b = shared(numpy.asarray(rng.uniform(low=-.05, high=.05, size=b_shp), dtype=dtype))
+        #TODO: make w_range a parameter to new as well?
+        w_range = (-1.0 / numpy.sqrt(filter_shape[0] * filter_shape[1] * n_imgs),
+                   1.0 / numpy.sqrt(filter_shape[0] * filter_shape[1] * n_imgs))
+
+        w = shared(numpy.asarray(rng.uniform(low=w_range[0], high=w_range[1], size=w_shp), dtype=dtype))
+        b = shared(numpy.asarray(rng.uniform(low=-.0, high=0., size=b_shp), dtype=dtype))
 
         if isinstance(squash_fn, str):
             squash_fn = squash(squash_fn)