MLE of lambda parameter in PowerTransform bijector
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- python, tensorflow
调研方向
首先复现提供的 PowerTransform 和 TransformedDistribution 训练循环,然后在报告的 lambda 值下,将其对数概率和正向 Jacobian 与 scipy.stats.boxcox 进行比较。确定差异是来自训练过程还是 PowerTransform 的行为;解释清楚该不匹配或识别出一个可复现的缺陷,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Hi everyone, I'm trying tofind the optimal lambda parameter of the PowerTransform bijector with maximum lilkelihood estimation.
In order to do so I had to modify the constructor of the bijector in order to allow power to be a trainable tf.Variable.
Then code is the following:
import matplotlib.pyplot as plt
import numpy as np
import tensorflow as tf
from tensorflow_probability import bijectors as tfb
from tensorflow_probability import distributions as tfd
from scipy.stats import boxcox
np.random.seed(42)
tf.random.set_seed(42)
# Data exponential generation
data_dist = tfd.Sample(tfd.Exponential(1.), sample_shape=1000)
x_train = data_dist.sample()
plt.hist(x_train.numpy(), bins=120, density=True, alpha=0.6, color='blue', label='Samples')
plt.show()
nf = tfd.TransformedDistribution(
tfd.Normal(loc=0, scale=1),
bijector=tfb.PowerTransform(power=tf.Variable(initial_value=1., name='power'))
)
# Training loop
num_steps = 2000
optimizer = tf.keras.optimizers.Adam(learning_rate=0.001)
for step in range(num_steps):
with tf.GradientTape() as tape:
loss = -tf.reduce_sum(nf.log_prob(x_train))
grads = tape.gradient(loss, nf.trainable_variables)
optimizer.apply_gradients(zip(grads, nf.trainable_variables))
if step % 100 == 0:
print(f"Step {step}, Loss: {loss.numpy()}, Grads: {grads}, Power: {nf.trainable_variables[0].numpy()}")
_, llm_lmbda = boxcox(x_train, lmbda=None)
print(f"Scipy MLE power is: {llm_lmbda}") # 0.24647694003577084
print(f"My MLE power is: {nf.trainable_variables[0].numpy()}") # 0.6407918334007263
z_samples = nf.sample(1000)
plt.hist(z_samples.numpy(), bins=120, density=True, alpha=0.6, color='green', label='Samples')
plt.show()
The estimation with the MLE from the scipy library gives lambda = 0.25 but mine gives lambda = 0.64. If I use the bijector with a static value of 0.25 I can recover a distribution that is closer to the original exponential so I believe that there might be a problem with the training procedure or with the computation of the forward Jacobian in the PowerTransform bijector but I can't find it.
Anyone can help with this?
- 主要语言
- Jupyter Notebook
- 星标
- 4.4k
- 派生
- 1.1k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
tensorflow/probability 的其他 Issue
-
KL divergence between two `TransformedDistribution`s with a shared non-injective bijector (`AbsoluteValue`) returns the base KL可能已有人在做 @Andreas-Hum 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
tensorflow/probability#2036 ·
-
难度 4/5 3-5 天 新手友好度 54/100
tensorflow/probability#2040 ·
-
难度 3/5 1-2 天 新手友好度 68/100
tensorflow/probability#2034 ·
-
难度 5/5 一周以上 新手友好度 35/100
tensorflow/probability#2021 ·
-
难度 4/5 3-5 天 新手友好度 30/100
tensorflow/probability#2015 ·
查看 tensorflow/probability 的全部 Issue
相似的 Issue
-
OODKnowledgeMetric never parses answer letters and divides by zero when all answers are refusals可能已有人在做 @davrens101 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
stanford-crfm/helm#4379 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
JdeRobot/PerceptionMetrics#680 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
TuringLang/Turing.jl#2917 ·
维护者通常 1 天内回复
-
bug good first issue
难度 2/5 1-3 小时 新手友好度 84/100
Selectus2/trainers-rb#29 ·
-
test_issue1702 hardware test fails in a full `-m gpu` run: it reads a process-wide pinned-memory counter that test_issue1174 leaves non-zero可能已有人在做 @jafarovvvvvvv 今天认领。 未关闭bug claimed difficulty:2
难度 2/5 1-3 小时 新手友好度 75/100
MakazhanAlpamys/Soup#2680 · 2 条评论 ·
维护者通常 1 天内回复