diff 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
line wrap: on
line diff
--- a/deep/crbm/mnist_crbm.py	Sun Apr 18 11:54:57 2010 -0400
+++ b/deep/crbm/mnist_crbm.py	Sun Apr 18 13:21:21 2010 -0400
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import sys
+import os, os.path
 
 # do this before importing custom modules
 from mnist_config import *
@@ -8,10 +9,9 @@
 if not (len(sys.argv) > 1 and sys.argv[1] in \
             ('test_jobman_entrypoint', 'run_local')):
     # in those cases don't use isolated code, use dev code
+    print "Running experiment isolation code"
     isolate_experiment()
 
-import os, os.path
-
 import numpy as N
 
 import theano
@@ -32,10 +32,13 @@
 
 import utils
 
-if not (len(sys.argv) > 1 and sys.argv[1] in \
-            ('jobman_insert',)):
+def setup_workdir():
     if not os.path.exists(IMAGE_OUTPUT_DIR):
         os.mkdir(IMAGE_OUTPUT_DIR)
+        if not os.path.exists(IMAGE_OUTPUT_DIR):
+            print "For some reason mkdir(IMAGE_OUTPUT_DIR) failed!"
+            sys.exit(1)
+        print "Created image output dir"
     elif os.path.isfile(IMAGE_OUTPUT_DIR):
         print "IMAGE_OUTPUT_DIR is not a directory!"
         sys.exit(1)
@@ -49,6 +52,8 @@
     pylearn.version.record_versions(state,[theano,ift6266,pylearn])
     channel.save()
 
+    setup_workdir()
+
     crbm = MnistCrbm(state)
     crbm.train()
 
@@ -222,6 +227,7 @@
         chanmock = DD({'COMPLETE':0,'save':(lambda:None)})
         jobman_entrypoint(DEFAULT_STATE, chanmock)
     elif args[0] == 'run_default':
+        setup_workdir()
         mc = MnistCrbm(DEFAULT_STATE)
         mc.train()