comparison deep/crbm/mnist_crbm.py @ 344:ed1c0830681e

Correcting bugs after trying to launch on cluster. Image dir must be created after workdir is changed.
author fsavard
date Sun, 18 Apr 2010 13:21:21 -0400
parents 82dae7c46046
children
comparison
equal deleted inserted replaced
343:82dae7c46046 344:ed1c0830681e
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 import sys 3 import sys
4 import os, os.path
4 5
5 # do this before importing custom modules 6 # do this before importing custom modules
6 from mnist_config import * 7 from mnist_config import *
7 8
8 if not (len(sys.argv) > 1 and sys.argv[1] in \ 9 if not (len(sys.argv) > 1 and sys.argv[1] in \
9 ('test_jobman_entrypoint', 'run_local')): 10 ('test_jobman_entrypoint', 'run_local')):
10 # in those cases don't use isolated code, use dev code 11 # in those cases don't use isolated code, use dev code
12 print "Running experiment isolation code"
11 isolate_experiment() 13 isolate_experiment()
12
13 import os, os.path
14 14
15 import numpy as N 15 import numpy as N
16 16
17 import theano 17 import theano
18 import theano.tensor as T 18 import theano.tensor as T
30 30
31 import ift6266 31 import ift6266
32 32
33 import utils 33 import utils
34 34
35 if not (len(sys.argv) > 1 and sys.argv[1] in \ 35 def setup_workdir():
36 ('jobman_insert',)):
37 if not os.path.exists(IMAGE_OUTPUT_DIR): 36 if not os.path.exists(IMAGE_OUTPUT_DIR):
38 os.mkdir(IMAGE_OUTPUT_DIR) 37 os.mkdir(IMAGE_OUTPUT_DIR)
38 if not os.path.exists(IMAGE_OUTPUT_DIR):
39 print "For some reason mkdir(IMAGE_OUTPUT_DIR) failed!"
40 sys.exit(1)
41 print "Created image output dir"
39 elif os.path.isfile(IMAGE_OUTPUT_DIR): 42 elif os.path.isfile(IMAGE_OUTPUT_DIR):
40 print "IMAGE_OUTPUT_DIR is not a directory!" 43 print "IMAGE_OUTPUT_DIR is not a directory!"
41 sys.exit(1) 44 sys.exit(1)
42 45
43 #def filename_from_time(suffix): 46 #def filename_from_time(suffix):
46 49
47 def jobman_entrypoint(state, channel): 50 def jobman_entrypoint(state, channel):
48 # record mercurial versions of each package 51 # record mercurial versions of each package
49 pylearn.version.record_versions(state,[theano,ift6266,pylearn]) 52 pylearn.version.record_versions(state,[theano,ift6266,pylearn])
50 channel.save() 53 channel.save()
54
55 setup_workdir()
51 56
52 crbm = MnistCrbm(state) 57 crbm = MnistCrbm(state)
53 crbm.train() 58 crbm.train()
54 59
55 return channel.COMPLETE 60 return channel.COMPLETE
220 utils.jobman_insert_job_vals(JOBDB, EXPERIMENT_PATH, JOB_VALS) 225 utils.jobman_insert_job_vals(JOBDB, EXPERIMENT_PATH, JOB_VALS)
221 elif args[0] == 'test_jobman_entrypoint': 226 elif args[0] == 'test_jobman_entrypoint':
222 chanmock = DD({'COMPLETE':0,'save':(lambda:None)}) 227 chanmock = DD({'COMPLETE':0,'save':(lambda:None)})
223 jobman_entrypoint(DEFAULT_STATE, chanmock) 228 jobman_entrypoint(DEFAULT_STATE, chanmock)
224 elif args[0] == 'run_default': 229 elif args[0] == 'run_default':
230 setup_workdir()
225 mc = MnistCrbm(DEFAULT_STATE) 231 mc = MnistCrbm(DEFAULT_STATE)
226 mc.train() 232 mc.train()
227 233
228 234