예제 #1
0
    def init(self,
             desc_name,
             expr_name,
             run_name,
             args=None,
             highlight_args=None,
             configs=None):
        desc, _ = Desc.get_or_create(desc_name=desc_name)
        expr, _ = Experiment.get_or_create(desc=desc, expr_name=expr_name)
        run = Run(expr=expr, run_name=run_name, command=' '.join(sys.argv))

        run.args = ''
        run.highlight_args = ''

        if args is not None:
            run.args = io.dumps_json(args.__dict__)
            if highlight_args is not None and hasattr(highlight_args,
                                                      'highlight_args'):
                run.highlight_args = io.dumps_json(
                    get_highlight_args(args, highlight_args))

        run.configs = ''
        run.highlight_configs = ''

        if configs is not None:
            run.configs = io.dumps_json(configs)
            if getattr(args, 'configs', None) is not None:
                run.highlight_configs = io.dumps_json(args.configs.kvs)

        save_retry(run)

        self.desc = desc
        self.expr = expr
        self.run = run
예제 #2
0
def dump_metainfo(metainfo=None, **kwargs):
    if metainfo is None:
        metainfo = {}
    metainfo.update(kwargs)
    metainfo.setdefault('_cmd', ' '.join(sys.argv))
    metainfo.setdefault('_git', get_git_revision_hash())
    return io.dumps_json(metainfo, compressed=False)
예제 #3
0
 def _dump_meters(self, meters, mode):
     if args.summary_file is not None:
         meters_kv = meters._canonize_values('avg')
         meters_kv['mode'] = mode
         meters_kv['epoch'] = self.current_epoch
         with open(args.summary_file, 'a') as f:
             f.write(io.dumps_json(meters_kv))
             f.write('\n')
예제 #4
0
    def get(self):
        spec = json.loads(self.get_argument('spec'))
        record = tensorboard_manager.start(spec)
        host = self.request.host
        if ':' in host:
            host = host[:host.find(':')]

        if record is not None:
            self.write(
                io.dumps_json(
                    {'url': 'http://' + host + ':' + str(record['port'])}))
        else:
            self.write(
                io.dumps_json({
                    'error':
                    'Fail to start the tensorboard visualizer: got empty selection.'
                }))
예제 #5
0
 def get(self):
     spec = json.loads(self.get_argument('spec'))
     record = tensorboard_manager.start(spec)
     host = self.request.host
     if ':' in host:
         host = host[:host.find(':')]
     self.write(
         io.dumps_json(
             {'url': 'http://' + host + ':' + str(record['port'])}))
예제 #6
0
 def _log_metric_inner(self, key, value, target, update_func=None):
     if target.metrics is None:
         current = dict()
     else:
         current = io.loads_json(target.metrics)
     if update_func is not None:
         if key in current:
             current[key] = update_func(current[key], value)
         else:
             current[key] = value
     else:
         current[key] = value
     target.metrics = io.dumps_json(current)
     save_retry(target)
예제 #7
0
파일: train.py 프로젝트: dair-iitd/1oML
 def _dump_meters(self, meters, mode):
     if args.summary_file is not None:
         meters_kv = meters._canonize_values('avg')
         meters_kv['mode'] = mode
         meters_kv['time'] = time.time()
         meters_kv['htime'] = str(datetime.datetime.now())
         meters_kv['config'] = args.dump_dir
         meters_kv['lr'] = self._optimizer.param_groups[0]['lr']
         if mode == 'train':
             meters_kv['epoch'] = self.current_epoch
             meters_kv['data_file'] = args.train_file
         else:
             meters_kv['epoch'] = -1
             meters_kv['data_file'] = args.test_file
             meters_kv['error distribution'] = "-".join([
                 str(self.error_distribution[k])
                 for k in sorted(self.error_distribution.keys())
             ])
         with open(args.summary_file, 'a') as f:
             f.write(io.dumps_json(meters_kv))
             f.write('\n')
예제 #8
0
 def update_extra_info(self):
     self.extra_info = io.dumps_json(self.extra_info_dict)
예제 #9
0
 def dump(self, filename, values='avg'):
     meters_kv = self._canonize_values(values)
     with open(filename, 'a') as f:
         f.write(io.dumps_json(meters_kv, compressed=False))
         f.write('\n')