Esempio n. 1
0
    Option('finetune_momentum', 'momentum for finetuning when backprop used [%default]', 0.5, converter=float),
    Option('finetune_onlylast', 'epochs where only not-pretrained upper layer is updated [%default]', 0, converter=int),
    Option('finetune_online_learning', 'online learning [%default]', '0', converter=int),
]

cfg = Config(options, usage = "usage: %prog [options]")

try:
    sys.path.insert(0,os.path.join(os.getenv('HOME'),'bin'))
    import optcomplete
    optcomplete.autocomplete(cfg._parser)
except ImportError:
    pass


cfg.grab_from_argv(sys.argv)    # to fetch the config file name
try:
    os.mkdir(cfg.workdir)
except:pass
cfg.config_file = os.path.join(cfg.workdir, "pyrbm.ini")

print "Loading configuration from ", cfg.config_file

if os.path.exists(cfg.config_file):
    cfg.grab_from_file(cfg.config_file)
cfg.grab_from_argv(sys.argv)    # overwrite using cmdline
cfg.num_layers=len(cfg.l_size)+1
dic = cfg.to_dict()
cfgk= dic.keys(); cfgk.sort()
if (cfg.project_down or cfg.gethidrep or cfg.continue_learning) and cfg.load==pyrbm.LoadType.none:
    cfg.load=pyrbm.LoadType.latest
Esempio n. 2
0
    Option('finetune_online_learning',
           'online learning [%default]',
           '0',
           converter=int),
]

cfg = Config(options, usage="usage: %prog [options]")

try:
    sys.path.insert(0, os.path.join(os.getenv('HOME'), 'bin'))
    import optcomplete
    optcomplete.autocomplete(cfg._parser)
except ImportError:
    pass

cfg.grab_from_argv(sys.argv)  # to fetch the config file name
try:
    os.mkdir(cfg.workdir)
except:
    pass
cfg.config_file = os.path.join(cfg.workdir, "pyrbm.ini")

print "Loading configuration from ", cfg.config_file

if os.path.exists(cfg.config_file):
    cfg.grab_from_file(cfg.config_file)
cfg.grab_from_argv(sys.argv)  # overwrite using cmdline
cfg.num_layers = len(cfg.l_size) + 1
dic = cfg.to_dict()
cfgk = dic.keys()
cfgk.sort()
Esempio n. 3
0
        Option('chains',     'number of markov chains [%default]', 512, short_name='c', converter=int),
        Option('steps', 'number of annealing steps (don\'t change this at the moment [%default]', 145000,  short_name='s', converter=int),
        Option('postfix',     'index/postfix of file [%default]', "pretrain", short_name='i', converter=str),
        Option('utype',  'type of visible units (cont/gaussian/binary) [%default]', 'binary.binary', short_name='V', converter=lambda x: [eval("UnitType."+y, loc) for y in x.split(".")]),
        Option('path',    'Path to weights [%default]', '.', short_name='p', converter=str),
]

    cfg = Config(options, usage = "usage: %prog [options]")
    try:
        sys.path.insert(0,os.path.join(os.getenv('HOME'),'bin'))
        import optcomplete
        optcomplete.autocomplete(cfg._parser)
    except ImportError:
        pass

    cfg.grab_from_argv(sys.argv)
    cfg.batchsize=-1 # not used, only compatibility with dataset classes


    #load pickle with rbm cfg
    fn = os.path.join(cfg.path, "info-0.pickle")
    with open(fn,"r") as f:
        rbmcfg=cPickle.load(f)
    cfg.dataset   = rbmcfg['dataset']

    if cfg.dataset==Dataset.mnist:
        dataset = MNISTData(cfg,"/home/local/datasets/MNIST")
    elif cfg.dataset==Dataset.shifter:
        dataset = ShifterData(cfg,"/home/local/datasets/")
    elif cfg.dataset==Dataset.bars_and_stripes:
        dataset = BarsAndStripesData(cfg,"/home/local/datasets/")