https://github.com/avik-pal/simpleconfig.jl
A simple way to specify experiment configurations
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 1 committers (100.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.3%) to scientific vocabulary
Repository
A simple way to specify experiment configurations
Basic Info
- Host: GitHub
- Owner: avik-pal
- License: mit
- Language: Julia
- Default Branch: main
- Size: 8.79 KB
Statistics
- Stars: 17
- Watchers: 2
- Forks: 0
- Open Issues: 1
- Releases: 0
Metadata Files
README.md
SimpleConfig
Composes Configurations.jl with ArgParse.jl making it easier to write config files.
For users from the python world, this is similar to the functionality provided by ml_collections.
Installation
To install the module, use Julia's package manager: start pkg mode by pressing ] and then enter:
julia
(v1.7) pkg> add SimpleConfig
Usage
QuickStart
This package simply extends Configurations.jl. Follow the tutorial in its
documentation, to define a
configuration. For example:
```julia using SimpleConfig
@option struct SchedulerConfig name::String = "cosine" minlearningrate::Float32 = 1f-4 end
@option struct OptimizerConfig name::String = "adam" learning_rate::Float32 = 3f-3 scheduler::SchedulerConfig end
@option struct ModelConfig backbone::String = "resnet18" stage_size = [2, 2, 2, 2] end
@option struct ExperimentConfig global_seed::Int64 = 0 optimizer::OptimizerConfig model::ModelConfig end ```
One way to initialize the configuration would be to use the from_dict function from
Configurations.jl. For example:
```julia using Configurations
defaults = Dict("globalseed" => 0, "optimizer" => Dict("name" => "adam", "learningrate" => 3f-3, "scheduler" => Dict("name" => "cosine", "minlearningrate" => 1f-4)), "model" => Dict("backbone" => "resnet18", "stage_size" => [2, 2, 2, 2]))
cfg = from_dict(ExperimentConfig, defaults) ```
The main problem with this approach is that it is hard to use use in scripts, or when
running batch experiments with different configurations. We provide a simple function
define_configuration, which automatically creates a argparse settings, so that the
configurations can be updated using command line arguments.
julia
cfg = define_configuration(ExperimentConfig, defaults)
This simple line in your script will allow you to update the configuration via command
line arguments. The structure is extremely self-explainatory, run the script using
--help to see the available options.
Basic Example Script
If we run the script examples/script_dict.jl with the following command:
```julia $ julia --project=. examples/script_dict.jl --help
usage: script_dict.jl [--cfg.globalseed CFG.GLOBALSEED] [--cfg.optimizer.name CFG.OPTIMIZER.NAME] [--cfg.optimizer.learningrate CFG.OPTIMIZER.LEARNINGRATE] [--cfg.optimizer.scheduler.name CFG.OPTIMIZER.SCHEDULER.NAME] [--cfg.optimizer.scheduler.minlearningrate CFG.OPTIMIZER.SCHEDULER.MINLEARNINGRATE] [--cfg.model.backbone CFG.MODEL.BACKBONE] [--cfg.model.stagesize CFG.MODEL.STAGESIZE] [-h]
optional arguments: --cfg.globalseed CFG.GLOBALSEED (type: Int64, default: 0) --cfg.optimizer.name CFG.OPTIMIZER.NAME (default: "adam") --cfg.optimizer.learningrate CFG.OPTIMIZER.LEARNINGRATE (type: Float32, default: 0.003) --cfg.optimizer.scheduler.name CFG.OPTIMIZER.SCHEDULER.NAME (default: "cosine") --cfg.optimizer.scheduler.minlearningrate CFG.OPTIMIZER.SCHEDULER.MINLEARNINGRATE (type: Float32, default: 0.0001) --cfg.model.backbone CFG.MODEL.BACKBONE (default: "resnet18") --cfg.model.stagesize CFG.MODEL.STAGESIZE (type: Vector{Int64}, default: [2, 2, 2, 2]) -h, --help show this help message and exit ```
Specifying Defaults in Config Files
Specifying defaults in a dictionary in the script is not great for version controlling
experiments. Typically we recommend storing the defaults in config files, and use
command line arguments for hyper-parameters like seed. In this case, we need to make
a very simple change.
julia
cfg = define_configuration(ExperimentConfig, filename)
where filename can be a .toml, .yml or .json file. See examples/script_file.jl
for an example script.
Logging Configuration
Logging a deeply nested struct is typically not supported OOTB by most loggers. We provide
a simple function flatten_configuration which takes the configuration and returns a
single level dictionary which can be easily logged.
Known Issues
Using field types like
Symboldoesn't work with loading the defaults from a file.NTuples parsing is implemented via type piracy.
Owner
- Name: Avik Pal
- Login: avik-pal
- Kind: user
- Location: Cambridge, MA
- Company: Massachusetts Institute of Technology
- Website: https://avik-pal.github.io
- Twitter: avikpal1410
- Repositories: 46
- Profile: https://github.com/avik-pal
PhD Student @mit || Prev: BTech CSE IITK
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Committers
Last synced: 8 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Avik Pal | a****l@m****u | 3 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 8 months ago
All Time
- Total issues: 2
- Total pull requests: 0
- Average time to close issues: less than a minute
- Average time to close pull requests: N/A
- Total issue authors: 2
- Total pull request authors: 0
- Average comments per issue: 1.5
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- Roger-luo (1)
- JuliaTagBot (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
juliahub.com: SimpleConfig
A simple way to specify experiment configurations
- Documentation: https://docs.juliahub.com/General/SimpleConfig/stable/
- License: MIT
-
Latest release: 0.1.0
published over 3 years ago