Skip to content

jonkhler/mlparams

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mlparams

minimalist hyperparam configuration files stored as YAML

usage

from dataclasses import dataclass

from mlparams import from_yaml, to_yaml


@dataclass(frozen=True)
class SomeOtherConfiguration:
  dtype: str
  shape: tuple[int, ...]

@dataclass(frozen=True)
class SomeConfiguration:
  foo: str
  bar: dict[str, int]
  subconfig: SomeOtherConfiguration
  
  
config = SomeConfiguration(
  foo="foo",
  bar={
    "asdf": 5
  },
  subconfig=SomeOtherConfiguration(
    dtype="float32",
    shape=(2, 3, 4)
  )
)
  
# store to YAML file
with open("myconfig.yaml", "w") as f:
  to_yaml(config, f)
  
  
# load from YAML file with correct type info
with open("myconfig.yaml", "r") as f:
  config = from_yaml(SomeConfiguration, f)

Will create / parse the following YAML config file

foo: "foo"
bar:
  asdf: 5
subconfig:
  dtype: "float32"
  shape: [2, 3, 4]

About

minimalist configuration files stored as YAML

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages