From 80fe8bdf7cfad4ab1b4a8cfc0046c4b0b86a52aa Mon Sep 17 00:00:00 2001 From: Madan Ram Date: Tue, 17 Feb 2015 12:12:30 +0530 Subject: [PATCH] Update ae.py I was reading your code as a reference. Then I found that you are converting array to list for converting it to floatX dtype, but is is much efficient not to convert to list then to array rather we can directly convert to floatX. I have also added corruption quantity. --- ae.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ae.py b/ae.py index 4af63b9..e546c93 100644 --- a/ae.py +++ b/ae.py @@ -241,7 +241,7 @@ def fit(self, batch_size=100, n_epochs=20, lr_scaler=0.998, - weights_file="out/ae_weights_mnist.npy"): + weights_file="out/ae_weights_mnist.npy", corruption_quantity=0.0): """ Fit the data to the autoencoder model. Basically this performs the learning. @@ -250,7 +250,8 @@ def fit(self, raise Exception("Data can't be empty.") index = T.lscalar('index') - data_shared = theano.shared(numpy.asarray(data.tolist(), dtype=theano.config.floatX)) + data = data * np.random.binomial(size=data.shape, n=1,p=1 - corruption_quantity) + data_shared = theano.shared(numpy.asarray(data, dtype=theano.config.floatX)) n_batches = data.shape[0] / batch_size (cost, updates) = self.get_sgd_updates(learning_rate, lr_scaler, batch_size) train_ae = theano.function([index],