示例#1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--out",required=True,help="The name of the yaml file produced")
    parser.add_argument("--template",required=True,help="YAML template")
    parser.add_argument("--hparams",required=True,help="Hyper-parameters configuration")
    parser.add_argument("--force",action='store_true',help="Force to overwrite the old yaml file produced")
    parser.add_argument("--range",nargs=2,type=int,help="Subrange of files to execute")
    options = parser.parse_args()

    out = options.out
    template = options.template
    hparams = options.hparams
    force = options.force

    print options

    # Generates a list of hyper-parameter names and a list of 
    # hyper-parameter values
    hpnames, hpvalues = generate_params(hparamfile=hparams,
                                        generate="uniform",
                                        search_mode="fix-grid-search")

    # Writes template with each hyper-parameter settings in  
    # succesive files and returns the name of the files
    files = write_files(template="".join(open(template,"r")),hpnames=hpnames,
                        hpvalues=hpvalues,save_path=out,force=force)

    if options.range:
        if options.range[1]==-1:
            options.range[1] = len(files)
        assert options.range[0] < options.range[1]
        iterator = xrange(*options.range)
    else:
        iterator = xrange(0,len(files))

    print list(iterator)

    print_error_message("errors\n",out,"w")
    from pylearn2.utils import serial

    for i in iterator:#xrange(0,len(files)):
        f = files[i]
        print f
        try:
           serial.load_train_file(f).main_loop()
        except BaseException as e:
            print traceback.format_exc()
            print e
            print_error_message("%s : %s\n" % (f,str(e)),out)
示例#2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--out",
                        required=True,
                        help="The name of the yaml file produced")
    parser.add_argument("--template", required=True, help="YAML template")
    parser.add_argument("--hparams",
                        required=True,
                        help="Hyper-parameters configuration")
    parser.add_argument("--force",
                        action='store_true',
                        help="Force to overwrite the old yaml file produced")
    options = parser.parse_args()

    out = options.out
    template = options.template
    hparams = options.hparams
    force = options.force

    print options

    # Generates a list of hyper-parameter names and a list of
    # hyper-parameter values
    hpnames, hpvalues = generate_params(hparamfile=hparams,
                                        generate="uniform",
                                        search_mode="fix-grid-search")

    # Writes template with each hyper-parameter settings in
    # succesive files and returns the name of the files
    files = write_files(template="".join(open(template, "r")),
                        hpnames=hpnames,
                        hpvalues=hpvalues,
                        save_path=out,
                        force=force)

    print_error_message("errors\n", out, "w")
    from pylearn2.utils import serial

    for i in xrange(0, len(files)):
        f = files[i]
        try:
            serial.load_train_file(f).main_loop()
        except BaseException as e:
            print traceback.format_exc()
            print e
            print_error_message("%s : %s\n" % (f, str(e)), out)
示例#3
0
OUT = "/yaml/test.yaml"
TEMPLATE = DIR+"template.yaml"
HPARAMS = "hparams.conf"

if __name__ == "__main__":

#    for transformation in ['translate','scale','rotate','flip','gaussian','sharpen','denoize','occlusion','halfface']:
#    for transformation in ['scale','rotate','flip','gaussian','sharpen','denoize','occlusion','halfface']:
    for transformation in ['denoize','sharpen']:
        out = DIR+transformation+OUT
        t_template = "".join(open(DIR+transformation+"/"+transformation+".yaml",'r'))

        # Generates a list of hyper-parameter names and a list of 
        # hyper-parameter values
        hpnames, hpvalues = generate_params(hparamfile=DIR+transformation+"/"+transformation+".conf",
                                            generate="log-uniform",
                                            search_mode="fix-grid-search")

        template = "".join(open(TEMPLATE,'r')) % {'transformations': t_template,'save_path':'%(save_path)s'}

        # Writes template with each hyper-parameter settings in  
        # succesive files and returns the name of the files
        files = write_files(template=template,hpnames=hpnames,
                            hpvalues=hpvalues,save_path=out,force=True)

#    files = write_files(template="".join(open(TEMPLATE),'r'),hpnames=hpnames,
#                        hpvalues=hpvalues,save_path=OUT)

        for f in files:
            serial.load_train_file(f).main_loop()
示例#4
0
import sys
import os

DIR = "/home/xavier/ift6266kaggle/conv/exp3/"

OUT = DIR+"yaml/test.yaml"
TEMPLATE = DIR+"template.yaml"
HPARAMS = DIR+"hparams.conf"

if __name__ == "__main__":

    # Generates a list of hyper-parameter names and a list of 
    # hyper-parameter values
    hpnames, hpvalues = generate_params(hparamfile=HPARAMS,
                                        generate="uniform",
                                        search_mode="fix-grid-search")

    force = len(sys.argv)>1 and sys.argv[1]=="--force"

    # Writes template with each hyper-parameter settings in  
    # succesive files and returns the name of the files
    files = write_files(template="".join(open(TEMPLATE,"r")),hpnames=hpnames,
                        hpvalues=hpvalues,save_path=OUT,force=force)

    for f in files:
        serial.load_train_file(f).main_loop()
#    for i in range(46-24):
#        f = DIR+"yaml/second%d.yaml" % (i+24)
#        print i+24,"on",46,"done"
#        serial.load_train_file(f).main_loop()
示例#5
0
from pylearn2.utils.shell import run_shell_command
from gen_yaml import generate_params, write_files

import os

DIR = "/data/lisatmp/ift6266h13/bouthilx/"

OUT = DIR+"yaml/test.yaml"
TEMPLATE = DIR+"gen_yaml/template.yaml"
HPARAMS = DIR+"gen_yaml/hparams.conf"

if __name__ == "__main__":

    # Generates a list of hyper-parameter names and a list of 
    # hyper-parameter values
    hpnames, hpvalues = generate_params(hparamfile=HPARAMS,
                                        generate="log-uniform",
                                        search_mode="fix-grid-search")

    # Writes template with each hyper-parameter settings in  
    # succesive files and returns the name of the files
    files = write_files(template=TEMPLATE,hpnames=hpnames,
                        hpvalues=hpvalues,save_path=OUT)

    command = """jobdispatch --condor --env=THEANO_FLAGS=device=gpu,floatX=float32,force_device=True --duree=48:00:00 --whitespace --gpu bash %(dir)strain.py \"{{%(files)s\"}}""" % {"dir":DIR,"files":files[0]}
    output, rc = run_shell_command(command)