Adjust per-series data pipeline, NB loss, and scheduler#191
Adjust per-series data pipeline, NB loss, and scheduler#191ShinDongWoon wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
| alpha = torch.clamp(dispersion, min=eps) | ||
| mu = torch.clamp(rate, min=eps) | ||
| r = 1.0 / alpha | ||
| log_p = torch.log(r) - torch.log(r + mu) | ||
| log1m_p = torch.log(mu) - torch.log(r + mu) | ||
| log_prob = ( | ||
| torch.lgamma(y + r) | ||
| - torch.lgamma(r) | ||
| log1p_alpha_mu = torch.log1p(alpha * mu) | ||
| log_alpha = torch.log(alpha) | ||
| log_mu = torch.log(mu) | ||
| inv_alpha = torch.reciprocal(alpha) | ||
| ll = ( | ||
| torch.lgamma(y + inv_alpha) | ||
| - torch.lgamma(inv_alpha) | ||
| - torch.lgamma(y + 1.0) | ||
| + r * log_p | ||
| + y * log1m_p | ||
| + inv_alpha * (-log1p_alpha_mu) | ||
| + y * (log_alpha + log_mu - log1p_alpha_mu) |
There was a problem hiding this comment.
[P1] Restore missing log(alpha) term in NB likelihood
The refactored negative_binomial_nll rewrites the log‑likelihood but omits the -(1/alpha) * log(alpha) component that was implicitly present before through r * log_p. The new implementation only subtracts inv_alpha * log1p(alpha*mu) and thus produces a value that differs from the standard negative‑binomial log‑likelihood for any dispersion ≠ 1. This changes both the loss scale and the gradient with respect to dispersion, so training will optimize the wrong objective and can no longer match the behaviour of the previous formulation. Reintroducing the -inv_alpha * log_alpha term before masking fixes the derivation.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68d4df402ba88328b5937643c21c75d2