Utilities for running parameter sweeps by providing a Jinja2 template and a parameter space (in YAML).
pip install sweepj2
Here's is an example script with three variables, viz. wn_grams
, learning_rate
and epoch
.
# 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
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:
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.