Skip to content

Instantly share code, notes, and snippets.

@allada
Last active July 16, 2023 02:08
Show Gist options
  • Save allada/cda6fe3e0dac028233922b86a7dccb29 to your computer and use it in GitHub Desktop.
Save allada/cda6fe3e0dac028233922b86a7dccb29 to your computer and use it in GitHub Desktop.
TRAINING_DATA_DIR = glob(["training/**"]);
TRAINING_SIZE = 10000
[genrule(
name = "sliced_training_" + i,
srcs = TRAINING_DATA_DIR,
outs = ["model_" + i + ".mdl"],
cmd = "./$(location train.py) --save_mode_to $@",
tools = ["train.py"],
) for i in range(0, TRAINING_SIZE)]
TRAIN_MODEL_FILES = ["model_" + i + ".mdl" for i in range(0, TRAINING_SIZE)]
genrule(
name = "model_list",
srcs = [],
outs = ["model_list.txt],
cmd = "sh -c 'for i in `seq 0 " + TRAINING_SIZE + "` ; do echo "model_$i.mdl"; done' > $@",
)
genrule(
name = "final_model",
srcs = TRAIN_MODEL_FILES + ["model_list.txt"],
outs = ["final_model.mdl"],
cmd = "./$(location train.py) --models_file $(location model_list.txt) --save_mode_to $@",
tools = ["make_final_model.py"],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment