File size: 686 Bytes
4010358
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Seed splits. Train/dev seeds and held-out seeds live in disjoint ranges, so a held-out firm
is never generated during training. Held-out seeds are for final evaluation only."""
from __future__ import annotations

RANGES = {"train": (0, 900_000), "dev": (900_000, 1_000_000), "heldout": (1_000_000, 2_000_000)}


def split_of(seed: int) -> str:
    for name, (lo, hi) in RANGES.items():
        if lo <= seed < hi:
            return name
    return "other"


def seeds(split: str, n: int, offset: int = 0) -> list[int]:
    lo, hi = RANGES[split]
    if lo + offset + n > hi:
        raise ValueError("not enough seeds in split")
    return list(range(lo + offset, lo + offset + n))