当前位置: 首页>>代码示例>>Python>>正文


Python Monitor.status方法代码示例

本文整理汇总了Python中monitor.Monitor.status方法的典型用法代码示例。如果您正苦于以下问题:Python Monitor.status方法的具体用法?Python Monitor.status怎么用?Python Monitor.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在monitor.Monitor的用法示例。


在下文中一共展示了Monitor.status方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from monitor import Monitor [as 别名]
# 或者: from monitor.Monitor import status [as 别名]
def main(args):
    monitor = Monitor('{}/{}_status.json'.format(args['out_dir'].rstrip('/'), args["model"]))

    try:
        if args['type'] == 'normal':
            from capgen import train

            _, validerr, _ = train(out_dir=args['out_dir'].rstrip('/'),
                                   data_dir=args['data_dir'].rstrip('/'),
                                   saveto=args["model"],
                                   attn_type='deterministic',
                                   reload_=args['reload'],
                                   dim_word=512,
                                   ctx_dim=512,
                                   dim=1800,
                                   n_layers_att=2,
                                   n_layers_out=1,
                                   n_layers_lstm=1,
                                   n_layers_init=2,
                                   n_words=10000,
                                   lstm_encoder=False,
                                   decay_c=0.,
                                   alpha_c=1.,
                                   prev2out=True,
                                   ctx2out=True,
                                   lrate=0.01,
                                   optimizer='adam',
                                   selector=True,
                                   patience=10,
                                   maxlen=100,
                                   batch_size=64,
                                   valid_batch_size=64,
                                   validFreq=2000,
                                   dispFreq=1,
                                   saveFreq=1000,
                                   sampleFreq=250,
                                   dataset="coco",
                                   use_dropout=True,
                                   use_dropout_lstm=False,
                                   save_per_epoch=False,
                                   monitor=monitor)
            print "Final cost: {:.2f}".format(validerr.mean())
        elif args['type'] == 't_attn':
            from capgen_text import train

            out_dir = args['out_dir'].rstrip('/')
            saveto  = args['model']
            _, validerr, _ = train(out_dir=out_dir,
                                   data_dir=args['data_dir'].rstrip('/'),
                                   saveto=saveto,
                                   attn_type='deterministic',
                                   reload_=args['reload'],
                                   dim_word=512,
                                   ctx_dim=512,
                                   tex_dim=args['tex_dim'],
                                   dim=1800,
                                   n_layers_att=2,
                                   n_layers_out=1,
                                   n_layers_lstm=1,
                                   n_layers_init=2,
                                   n_words=10000,
                                   lstm_encoder=False,
                                   lstm_encoder_context=args['lenc'],
                                   decay_c=0.,
                                   alpha_c=1.,
                                   prev2out=True,
                                   ctx2out=True,
                                   tex2out=True,
                                   lrate=0.01,
                                   optimizer='adam',
                                   selector=True,
                                   patience=10,
                                   maxlen=100,
                                   batch_size=32,
                                   valid_batch_size=32,
                                   validFreq=2000,
                                   dispFreq=1,
                                   saveFreq=1000,
                                   sampleFreq=250,
                                   dataset="coco",
                                   use_dropout=True,
                                   use_dropout_lstm=False,
                                   save_per_epoch=False,
                                   monitor=monitor)
            print "Final cost: {:.2f}".format(validerr.mean())

            # Store data preprocessing type in the options file
            with open('{}/{}.pkl'.format(out_dir, saveto)) as f_opts:
                opts = pkl.load(f_opts)
                opts['preproc_type'] = args['preproc_type']
                preproc_params = {}
                for param in args['preproc_params'].split(','):
                    if param:
                        key, value = param.split('=')
                        if value.isdigit():
                            value = int(value)
                        preproc_params[key] = value
                opts['preproc_params'] = preproc_params
                pkl.dump(opts, f_opts)
    except (KeyboardInterrupt, SystemExit):
#.........这里部分代码省略.........
开发者ID:flipvrijn,项目名称:arctic-captions,代码行数:103,代码来源:train.py


注:本文中的monitor.Monitor.status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。