{"record":{"id":"0b9a26dea57e03fb","repo":"rohitg00/ai-engineering-from-scratch","slug":"beta-must-be-in-0-1","errorCode":null,"errorMessage":"beta must be in (0, 1)","messagePattern":"beta must be in \\(0, 1\\)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phases/19-capstone-projects/44-cosine-lr-warmup/code/main.py","lineNumber":304,"sourceCode":"    def lr(self, step: int) -> float:\n        if step < 0:\n            raise ValueError(f\"step must be non-negative, got {step}\")\n        if step <= self.warmup_steps:\n            return self.lr_max * (step / self.warmup_steps)\n        return self.lr_max * math.sqrt(self.warmup_steps / step)\n\n\n@dataclass\nclass EWMA:\n    \"\"\"Exponentially weighted moving average of a scalar, useful for grad-norm smoothing.\"\"\"\n\n    beta: float\n    value: float = 0.0\n    initialized: bool = False\n\n    def __post_init__(self) -> None:\n        if not 0 < self.beta < 1:\n            raise ValueError(\"beta must be in (0, 1)\")\n\n    def update(self, sample: float) -> float:\n        if not self.initialized:\n            self.value = float(sample)\n            self.initialized = True\n            return self.value\n        self.value = self.beta * self.value + (1.0 - self.beta) * float(sample)\n        return self.value\n\n\n@dataclass\nclass StepLogSummary:\n    \"\"\"Reduction of a per-step log to the numbers a reviewer scans first.\"\"\"\n\n    steps: int\n    lr_peak: float\n    lr_final: float\n    grad_l2_peak: float","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/19-capstone-projects/44-cosine-lr-warmup/code/main.py#L286-L322","documentation":"Error \"beta must be in (0, 1)\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/19-capstone-projects/44-cosine-lr-warmup/code/main.py:304 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}