Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

jonkhler/mlparams

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
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

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.