Skip to content

Commit c475870

Browse files
committed
Always load the data from the data folder.
This work independently of the current directory.
1 parent a376f90 commit c475870

File tree

9 files changed

+16
-9
lines changed

9 files changed

+16
-9
lines changed

code/DBN.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def test_score():
257257

258258
def test_DBN(finetune_lr=0.1, pretraining_epochs=100,
259259
pretrain_lr=0.01, k=1, training_epochs=1000,
260-
dataset='../data/mnist.pkl.gz', batch_size=10):
260+
dataset='mnist.pkl.gz', batch_size=10):
261261
"""
262262
Demonstrates how to train and test a Deep Belief Network.
263263

code/SdA.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def test_score():
295295

296296
def test_SdA(finetune_lr=0.1, pretraining_epochs=15,
297297
pretrain_lr=0.001, training_epochs=1000,
298-
dataset='../data/mnist.pkl.gz', batch_size=1):
298+
dataset='mnist.pkl.gz', batch_size=1):
299299
"""
300300
Demonstrates how to train and test a stochastic denoising autoencoder.
301301

code/cA.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def get_cost_updates(self, contraction_level, learning_rate):
221221

222222

223223
def test_cA(learning_rate=0.01, training_epochs=20,
224-
dataset='../data/mnist.pkl.gz',
224+
dataset='mnist.pkl.gz',
225225
batch_size=10, output_folder='cA_plots', contraction_level=.1):
226226
"""
227227
This demo is tested on MNIST

code/convolutional_mlp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __init__(self, rng, input, filter_shape, image_shape, poolsize=(2, 2)):
104104

105105

106106
def evaluate_lenet5(learning_rate=0.1, n_epochs=200,
107-
dataset='../data/mnist.pkl.gz',
107+
dataset='mnist.pkl.gz',
108108
nkerns=[20, 50], batch_size=500):
109109
""" Demonstrates lenet on MNIST dataset
110110

code/dA.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def get_cost_updates(self, corruption_level, learning_rate):
237237

238238

239239
def test_dA(learning_rate=0.1, training_epochs=15,
240-
dataset='../data/mnist.pkl.gz',
240+
dataset='mnist.pkl.gz',
241241
batch_size=20, output_folder='dA_plots'):
242242

243243
"""

code/logistic_cg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def errors(self, y):
132132
raise NotImplementedError()
133133

134134

135-
def cg_optimization_mnist(n_epochs=50, mnist_pkl_gz='../data/mnist.pkl.gz'):
135+
def cg_optimization_mnist(n_epochs=50, mnist_pkl_gz='mnist.pkl.gz'):
136136
"""Demonstrate conjugate gradient optimization of a log-linear model
137137
138138
This is demonstrated on MNIST.

code/logistic_sgd.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ def load_data(dataset):
157157

158158
# Download the MNIST dataset if it is not present
159159
data_dir, data_file = os.path.split(dataset)
160+
if data_dir == "" and not os.path.isfile(dataset):
161+
# Check if dataset is in the data directory.
162+
new_path = os.path.join(os.path.split(os.path.split(__file__)[0])[0],
163+
"data", dataset)
164+
if os.path.isfile(new_path) or data_file == 'mnist.pkl.gz':
165+
dataset = new_path
166+
160167
if (not os.path.isfile(dataset)) and data_file == 'mnist.pkl.gz':
161168
import urllib
162169
origin = 'http://www.iro.umontreal.ca/~lisa/deep/data/mnist/mnist.pkl.gz'
@@ -211,7 +218,7 @@ def shared_dataset(data_xy, borrow=True):
211218

212219

213220
def sgd_optimization_mnist(learning_rate=0.13, n_epochs=1000,
214-
dataset='../data/mnist.pkl.gz',
221+
dataset='mnist.pkl.gz',
215222
batch_size=600):
216223
"""
217224
Demonstrate stochastic gradient descent optimization of a log-linear

code/mlp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def __init__(self, rng, input, n_in, n_hidden, n_out):
174174

175175

176176
def test_mlp(learning_rate=0.01, L1_reg=0.00, L2_reg=0.0001, n_epochs=1000,
177-
dataset='../data/mnist.pkl.gz', batch_size=20, n_hidden=500):
177+
dataset='mnist.pkl.gz', batch_size=20, n_hidden=500):
178178
"""
179179
Demonstrate stochastic gradient descent optimization for a multilayer
180180
perceptron

code/rbm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def get_reconstruction_cost(self, updates, pre_sigmoid_nv):
315315

316316

317317
def test_rbm(learning_rate=0.1, training_epochs=15,
318-
dataset='../data/mnist.pkl.gz', batch_size=20,
318+
dataset='mnist.pkl.gz', batch_size=20,
319319
n_chains=20, n_samples=10, output_folder='rbm_plots',
320320
n_hidden=500):
321321
"""

0 commit comments

Comments
 (0)