Spaces:
Running on Zero
Running on Zero
File size: 669 Bytes
9d24374 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | from __future__ import annotations
import json
import random
from pathlib import Path
import numpy as np
import torch
ROOT = Path(__file__).resolve().parents[1]
DATA_DIR = ROOT / 'data'
ARTIFACT_DIR = ROOT / 'artifacts'
def load_jsonl(path: str | Path) -> list[dict]:
rows = []
with Path(path).open(encoding='utf-8') as handle:
for line in handle:
line = line.strip()
if line:
rows.append(json.loads(line))
return rows
def set_seed(seed: int) -> None:
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
if torch.cuda.is_available():
torch.cuda.manual_seed_all(seed)
|