comparison pylearn/dataset_ops/image_patches.py @ 1511:9ffe5d6faee3

Auto white space fix.
author Frederic Bastien <nouiz@nouiz.org>
date Mon, 12 Sep 2011 11:47:23 -0400
parents 07b48bd449cd
children 6397233f3ccd
comparison
equal deleted inserted replaced
1510:07b48bd449cd 1511:9ffe5d6faee3
68 dct = ranzato_hinton_2010(path) 68 dct = ranzato_hinton_2010(path)
69 return dct['whitendata'].astype('float32') 69 return dct['whitendata'].astype('float32')
70 70
71 def undo_pca_filters_of_ranzato_hinton_2010(X, path=None): 71 def undo_pca_filters_of_ranzato_hinton_2010(X, path=None):
72 """Return tuple (R,G,B,None) of matrices for matrix `X` of filters (one per row) 72 """Return tuple (R,G,B,None) of matrices for matrix `X` of filters (one per row)
73 73
74 Return value can be passed to `image_tiling.tile_raster_images`. 74 Return value can be passed to `image_tiling.tile_raster_images`.
75 """ 75 """
76 dct = ranzato_hinton_2010(path) 76 dct = ranzato_hinton_2010(path)
77 X = numpy.dot(X, dct['invpcatransf'].T) 77 X = numpy.dot(X, dct['invpcatransf'].T)
78 return (X[:,:256], X[:,256:512], X[:,512:], None) 78 return (X[:,:256], X[:,256:512], X[:,512:], None)
83 img_shape=(16,16), 83 img_shape=(16,16),
84 min_dynamic_range=min_dynamic_range) 84 min_dynamic_range=min_dynamic_range)
85 image_tiling.save_tiled_raster_images(_img, fname) 85 image_tiling.save_tiled_raster_images(_img, fname)
86 86
87 def ranzato_hinton_2010_op(s_idx, 87 def ranzato_hinton_2010_op(s_idx,
88 split='train', 88 split='train',
89 dtype=theano.config.floatX, rasterized=True, 89 dtype=theano.config.floatX, rasterized=True,
90 center=True, 90 center=True,
91 unitvar=True, 91 unitvar=True,
92 fn=ranzato_hinton_2010_whitened_patches): 92 fn=ranzato_hinton_2010_whitened_patches):
93 N = 10240 93 N = 10240
103 103
104 if dtype != 'float32': 104 if dtype != 'float32':
105 raise NotImplementedError('dtype not float32') 105 raise NotImplementedError('dtype not float32')
106 106
107 op = TensorFnDataset(dtype, 107 op = TensorFnDataset(dtype,
108 bcast=(False,), 108 bcast=(False,),
109 fn=fn, 109 fn=fn,
110 single_shape=(105,)) 110 single_shape=(105,))
111 x = op(s_idx%N) 111 x = op(s_idx%N)
112 return x 112 return x
113