N = 1000 X = np.zeros((N, 2)) X[:, 0] = np.linspace(-1, 1, N) X[:, 1] = np.sin(2 * np.pi * np.linspace(-1, 1, N)) print X.shape from dae_untied_weights import DAE_untied_weights mydae = DAE_untied_weights(n_inputs=2, n_hiddens=32, act_func=['tanh', 'tanh'], want_plus_x=False) mydae.fit_with_decreasing_noise(X, [1.0, 0.5, 0.2, 0.1, 0.05, 0.01, 0.001], { 'method': 'fmin_bfgs', 'maxiter': 5000 }) clean_data = X import matplotlib matplotlib.use('Agg') import pylab def plot_grid_reconstruction_grid(mydae, outputfile, plotgrid_N_buckets=30, window_width=1.0, center=(0.0, 0.0)):
X = np.zeros((N,2)) X[:,0] = np.linspace(-1,1,N) X[:,1] = np.sin( 2* np.pi * np.linspace(-1,1,N) ) print X.shape from dae_untied_weights import DAE_untied_weights mydae = DAE_untied_weights(n_inputs = 2, n_hiddens = 32, act_func = ['tanh', 'tanh'], want_plus_x = False) mydae.fit_with_decreasing_noise(X, [1.0, 0.5, 0.2, 0.1, 0.05, 0.01, 0.001], {'method' : 'fmin_bfgs', 'maxiter' : 5000}) clean_data = X import matplotlib matplotlib.use('Agg') import pylab def plot_grid_reconstruction_grid(mydae, outputfile, plotgrid_N_buckets = 30, window_width = 1.0, center = (0.0,0.0)): (plotgrid_X, plotgrid_Y) = np.meshgrid(np.arange(center[0] - window_width, center[0] + window_width, 2 * window_width / plotgrid_N_buckets), np.arange(center[1] - window_width,
from dae_untied_weights import DAE_untied_weights mydae = DAE_untied_weights(n_inputs=784, n_hiddens=1024, act_func=['tanh', 'sigmoid']) #mydae.fit_with_decreasing_noise(mnist_train_data[0:2000,:], # [0.1, 0.05, 0.01, 0.001], # {'method' : 'fmin_cg', # 'maxiter' : 500, # 'gtol':0.001}) mydae.fit_with_decreasing_noise(mnist_train_data[0:2000, :], [0.1, 0.05, 0.01], { 'method': 'fmin_l_bfgs_b', 'maxiter': 500, 'm': 25 }) print mydae.s pkl_file = "/u/alaingui/umontreal/denoising_autoencoder/mcmc_pof/trained_models/mydae_2013_02_08.pkl" cPickle.dump( { 'Wc': mydae.Wc, 'Wb': mydae.Wb, 'b': mydae.b, 'c': mydae.c, 's': mydae.s, 'act_func': mydae.act_func }, open(pkl_file, "w"))
import cPickle mnist_dataset = cPickle.load(open('/data/lisa/data/mnist/mnist.pkl', 'rb')) mnist_train = mnist_dataset[0] mnist_train_data, mnist_train_labels = mnist_train from dae_untied_weights import DAE_untied_weights mydae = DAE_untied_weights(n_inputs = 784, n_hiddens = 1024, act_func = ['tanh', 'sigmoid']) #mydae.fit_with_decreasing_noise(mnist_train_data[0:2000,:], # [0.1, 0.05, 0.01, 0.001], # {'method' : 'fmin_cg', # 'maxiter' : 500, # 'gtol':0.001}) mydae.fit_with_decreasing_noise(mnist_train_data[0:2000,:], [0.1, 0.05, 0.01], {'method' : 'fmin_l_bfgs_b', 'maxiter' : 500, 'm':25}) print mydae.s pkl_file = "/u/alaingui/umontreal/denoising_autoencoder/mcmc_pof/trained_models/mydae_2013_02_08.pkl" cPickle.dump({'Wc':mydae.Wc, 'Wb':mydae.Wb, 'b':mydae.b, 'c':mydae.c, 's':mydae.s, 'act_func':mydae.act_func}, open(pkl_file, "w"))