Beispiel #1
0
    Option('gethidrep', 'whether to dump hidden rep after loading [%default]', False, converter=int),

    Option('pretrain', 'whether to dump matrices and configs without doing anything [%default]', True, converter=int),
    Option('finetune', 'whether to do fine tuning after initializing/learning weights [%default]', False, converter=int),
    Option('finetune_epochs', 'epochs for fine-tuning [%default]', 100, converter=int),
    Option('finetune_rprop', 'whether to use rprop for fine-tuning [%default]', 1, converter=int),
    Option('finetune_batch_size', 'size of minibatches for fine-tuning [%default]', 1000, converter=int),
    Option('finetune_softmax', 'whether to use softmax for fine-tuning [%default]', 1, converter=int),
    Option('finetune_learnrate', 'learnrate for finetuning [%default]', 0.01, converter=float),
    Option('finetune_cost', 'weight decay for finetuning [%default]', 0.001, converter=float),
    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")
Beispiel #2
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")
Beispiel #3
0
        cp.rnd_binarize(self.v)


if __name__=='__main__':

    loc = locals()
    options = [
        Option('device',    'GPU device to use [%default]', 0, short_name='d', converter=int),
        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)