https://github.com/ivotron/sweepj2
Generate a parameter sweep using jinja2
https://github.com/ivotron/sweepj2
Last synced: 17 days ago
JSON representation
Generate a parameter sweep using jinja2
- Host: GitHub
- URL: https://github.com/ivotron/sweepj2
- Owner: ivotron
- License: mit
- Created: 2018-07-13T19:52:33.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-12T08:09:04.000Z (almost 7 years ago)
- Last Synced: 2026-03-30T12:09:07.975Z (2 months ago)
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jinja2-based parameter sweep generation
[](https://travis-ci.org/ivotron/sweepj2)
Utilities for running parameter sweeps by providing a Jinja2 template and a parameter space (in YAML).
## Installation
```bash
pip install sweepj2
```
## Usage
Here's is an example script with three variables, viz. `wn_grams`, `learning_rate` and `epoch`.
```bash
# script.j2
./fasttext supervised -input cooking.train -output model_cooking \
-wordNgrams {{ wn_grams }} \
-lr {{ learning_rate }} \
-epoch {{ epoch }}
```
To do a parameter sweep over some parameter space, create a **YAML** file with the list of all the values corresponding to each variable in the script.
e.g. `space.yml`
```yaml
learning_rate: [ 0.3, 0.5, 0.8 ]
epoch: [ 20, 30 ]
wn_grams: [1, 2, 3, 4, 5 ]
```
You can generate the scripts with all the possible combinations from the YAML file by doing:
```bash
sweepj2 --template path/to/script.j2 --space path/to/space.yml --make-executable
```
You will find the generated scripts in `./sweepj2-output` directory, or you could mention the directory to save the files by using `--output` flag.
`make-executable` makes the resulting files executable. It can be skiped if you don't want the files executable.