`Weibull` and `Gumbel` `survival_function` / `log_survival_function` are 0 / -inf in the upper tail
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 70/100
Hướng nghiên cứu
Start in tensorflow_probability/python/distributions/weibull.py and gumbel.py, where survival_function, log_survival_function and log_cdf fall back to 1 - cdf and log1p(-cdf) after the cdf rounds to 1. Read the issue's reproduction snippet and run it in the upper tail to confirm 0 and -inf. Done means the Weibull and Gumbel values match the exact closed forms in the issue, with tests for the tail values added. Confirm the Gumbel gradient path depends on #2041 before deciding whether to include the other distributions.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Another one from the same comparison as #2041 :) In float32, tfd.Weibull(5., 1.).survival_function(2.) is exactly 0 and log_survival_function(2.) is -inf, where the true values are exp(-32) ≈ 1.27e-14 and -32. Gumbel has the same problem in its upper tail, and its log_cdf is -inf from about z = -4.5 down.
import tensorflow_probability as tfp
tfd = tfp.distributions
w = tfd.Weibull(concentration=5., scale=1.)
print(w.survival_function(2.).numpy()) # 0.0 exact exp(-32) = 1.27e-14
print(w.log_survival_function([1., 1.5, 2.]).numpy()) # [-1. -7.593729 -inf] exact -x**5: [-1, -7.59375, -32]
g = tfd.Gumbel(loc=0., scale=1.)
print(g.survival_function(20.).numpy()) # 0.0 exact 2.06e-09
print(g.log_survival_function(20.).numpy()) # -inf exact -20.0
print(g.log_cdf(-5.).numpy()) # -inf exact -exp(5) = -148.41
Both are a Uniform pushed through an inverted CDF bijector, and Uniform only defines _cdf, so these fall back to 1. - cdf and log1p(-cdf) after the cdf has already rounded to 1. The closed forms are one line each:
--- a/tensorflow_probability/python/distributions/weibull.py
+++ b/tensorflow_probability/python/distributions/weibull.py
def _log_prob(self, x):
return self._weibull_bijector.forward_log_det_jacobian(x, event_ndims=0)
+ def _log_survival_function(self, x):
+ return -(x / self.scale)**self.concentration
+
+ def _survival_function(self, x):
+ return tf.exp(self._log_survival_function(x))
+
--- a/tensorflow_probability/python/distributions/gumbel.py
+++ b/tensorflow_probability/python/distributions/gumbel.py
+ def _log_cdf(self, x):
+ return -tf.exp(-(x - self.loc) / self.scale)
+
+ def _log_survival_function(self, x):
+ return generic.log1mexp(tf.exp(-(x - self.loc) / self.scale))
+
+ def _survival_function(self, x):
+ return -tf.math.expm1(-tf.exp(-(x - self.loc) / self.scale))
The Gumbel log_survival_function goes through log1mexp, so its gradient past z = 17 also needs the fix in #2041.
Checked on 0.25.0 and tfp-nightly 0.26.0.dev20261112, CPU; main has the same code. GeneralizedExtremeValue, Moyal and Kumaraswamy are built the same way and also return 0, e.g. GeneralizedExtremeValue(0., 1., 0.1).survival_function(50.) is 0 where the exact value is 1.65e-8. Should those go in the same PR, or just these two to start?
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 4.4k
- Fork
- 1.1k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của tensorflow/probability
-
`tfp.math.log1mexp` has a NaN gradient for small inputs (reaches `OrderedLogistic.log_prob`)Có thể đã có người làm @aviralgarg05 đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
tensorflow/probability#2041 · 1 bình luận ·
-
KL divergence between two `TransformedDistribution`s with a shared non-injective bijector (`AbsoluteValue`) returns the base KLCó thể đã có người làm @Andreas-Hum đã nhận 19 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
tensorflow/probability#2036 ·
-
Chi2, Gamma, Beta and Binomial survival_function lose the upper tail because they fall back to 1 - cdfCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 54/100
tensorflow/probability#2040 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
tensorflow/probability#2034 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
tensorflow/probability#2021 ·
Tất cả issue của tensorflow/probability
Issue tương tự
-
priority:P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
osmlab/name-suggestion-index#13165 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
approved-for-pr area: extraction bug effort: S P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
hydra-db/selfgraph#343 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
automated endpoint-dead needs-curation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
almanac-data/climate-almanac#139 ·
Maintainer thường phản hồi trong vòng 1 ngày