Download code/verify_data.py from briscoooe/tiny-cube-value-iter: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/briscoooe/tiny-cube-value-iter/resolve/main/code/verify_data.py
- Command line
-
hf download hf://briscoooe/tiny-cube-value-iter/code/verify_data.py
-
curl -L -o verify_data.py https://huggingface.co/briscoooe/tiny-cube-value-iter/resolve/main/code/verify_data.py
1.55 kB
| """ | |
| Checks a generated dataset by replaying it: applies each recorded solution to its | |
| recorded state and confirms the cube ends solved. | |
| This is the one check worth running on every dataset before training on it. A | |
| generator bug that corrupts states or mislabels them is silent otherwise -- the | |
| model simply learns the wrong function and the failure only surfaces much later, | |
| as a bad benchmark number that looks like a modelling problem. | |
| """ | |
| import argparse, json, sys | |
| from gen_data import SOLVED, apply_sequence | |
| def main(): | |
| p = argparse.ArgumentParser(description=__doc__) | |
| p.add_argument("path") | |
| p.add_argument("--limit", type=int, default=0, help="Check only the first N rows (0 = all).") | |
| args = p.parse_args() | |
| checked = failed = 0 | |
| lengths = [] | |
| with open(args.path) as fh: | |
| for line in fh: | |
| if args.limit and checked >= args.limit: | |
| break | |
| row = json.loads(line) | |
| if len(row["state"]) != 54: | |
| failed += 1 | |
| continue | |
| moves = row["solution"].split() | |
| lengths.append(len(moves)) | |
| if apply_sequence(row["state"], moves) != SOLVED: | |
| failed += 1 | |
| checked += 1 | |
| mean = sum(lengths) / len(lengths) if lengths else 0 | |
| print(f"checked {checked}, solved {checked - failed}, FAILED {failed}") | |
| print(f"solution length: mean {mean:.2f} min {min(lengths, default=0)} max {max(lengths, default=0)}") | |
| sys.exit(1 if failed else 0) | |
| if __name__ == "__main__": | |
| main() | |