# HG changeset patch # User James Bergstra # Date 1243988481 14400 # Node ID 0eee6693f149ed67cdf5c51fad432c2c28a14b16 # Parent 80123baa454420a0a6c096f3ef7480d2787289fd better numeric stability in tile_image diff -r 80123baa4544 -r 0eee6693f149 pylearn/io/image_tiling.py --- a/pylearn/io/image_tiling.py Tue Jun 02 20:20:48 2009 -0400 +++ b/pylearn/io/image_tiling.py Tue Jun 02 20:21:21 2009 -0400 @@ -5,10 +5,10 @@ import numpy from PIL import Image -def scale_to_unit_interval(ndar): +def scale_to_unit_interval(ndar,eps=1e-8): ndar = ndar.copy() ndar -= ndar.min() - ndar *= 1.0 / ndar.max() + ndar *= 1.0 / (ndar.max()+eps) return ndar def tile_raster_images(X, img_shape, tile_shape, tile_spacing=(0,0),