Skip to content

yoshipon/tiny_conf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiny_conf

A light-weight configuration library whose API is inspired by Hydra and OmegaConf.

Basic usage

from argparse import ArgumentParser
import yaml

import tiny_conf as tc

parser = ArgumentParser()
parser.add_argument("config", type=str)
parser.add_argument("workspace", type=str)
args = parser.parse_args()

with open(args.config) as f:    
    config = vars(args) | tc.Struct(yaml.load(f, yaml.SafeLoader))

print("=" * 80)
print('Parameters')
print("-" * 80)
print(config)
print("=" * 80)

model = tc.instantiate(config.model)
optimizer = tc.instantiate(config.optimizer, params=model.parameters())
num_epoch: 200
batch_size: 32

loss:
  _target_: torch.nn.BCELoss

model:
  _target_: foo_bar_model.FooBarModel
  hidden_size: 64
  num_layers: 5

optimizer:
  _target_: torch.optim.Adam
  lr: 1.e-3
$ python main.py config.yaml ./checkpoint_path/

Known issue

  • There is no install instruction
  • There is no documents

About

A tiny Python module for configuration

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages