Exemplo n.º 1
0
    def m(self):
        m = Metadata()
        m['a'] = 10  # this is overwritten
        m['b'] = 'test'

        # namescope setitem
        with m.name_scope('c'):
            m['foo'] = 140

        # nested setitem
        m['a.foo'] = 120
        m['c.bar'] = 'what'

        return m
Exemplo n.º 2
0
    def m(self):
        m = Metadata()
        m['a'] = 10  # this is overwritten
        m['b'] = 'test'

        # namescope setitem
        with m.name_scope('c'):
            m['foo'] = 140

        # nested setitem
        m['a.foo'] = 120
        m['c.bar'] = 'what'

        return m
Exemplo n.º 3
0
    def default_format(cls, workspace):
        # get experiment name
        path = workspace.root
        name = os.path.split(path)[-1]

        # steps taken
        ckpt_nums = EditTrainingRun._checkpoint_numbers(workspace.checkpoints)
        steps = max(ckpt_nums) if ckpt_nums else 0

        # metadata
        meta = Metadata.from_file(workspace.metadata)
        bleu = meta.get('bleu_valid', None)
        gleu = meta.get('gleu_valid', None)
        ribes = meta.get('ribes_valid', None)
        chrf = meta.get('chrf_valid', None)
        loss = meta.get('loss_valid', None)
        dirty_repo = meta.get('dirty_repo', '?')

        # dataset
        config = Config.from_file(workspace.config)
        dataset = config.dataset.path

        return '{name:10} -- steps: {steps:<10}, loss: {loss:.2f}, dset: {dset:15}, bleu: {bleu:.2f}, gleu: {gleu:.2f}, ribes: {ribes:.2f}, chrf: {chrf:.2f} ' \
               'dirty_repo: {dirty_repo}'.format(
                name=name, dset=dataset, steps=steps, loss=loss, bleu=bleu, gleu=gleu, ribes=ribes, chrf=chrf, dirty_repo=dirty_repo)
    def __call__(self, path):
        full_path = join(path, self.file_path)
        try:
            # try loading as JSON
            with open(full_path, 'r') as f:
                x = json.load(f)
        except ValueError:
            # try loading as HOCON
            x = Metadata.from_file(full_path, fmt='hocon')

        return self.get_value_any(x, self.json_paths)
Exemplo n.º 5
0
    def __call__(self, path):
        full_path = join(path, self.file_path)
        try:
            # try loading as JSON
            with open(full_path, 'r') as f:
                x = json.load(f)
        except ValueError:
            # try loading as HOCON
            x = Metadata.from_file(full_path, fmt='hocon')

        for key in self.json_keys:
            x = x[key]

        return x