RFC: tracing variables within `JointDistribution`s
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 30/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- python
調査の方向性
まず、既存の JointDistribution.Root の動作と、issue で説明されている CDF/CMF/PDF/PMF 関連のメソッドを読んでください。前向きの生成プロセスにおける Trace のセマンティクスを定義し、その後、トレースされた値が model.sample() に現れる一方で、log_prob がそれらを無視し、式を再計算せずに残りの変数を受け入れられることを検証してください。
索引モデルが issue の本文から書いたものです。
説明
Background
Sometimes it would be useful to be able to trace intermediate values computed as part of a JointDistribution* model. The current solution to this is to make use of tfd.Deterministic. As an example, supposing we would like to trace the mean of a simple linear regression on a single feature, a user might write:
@tfd.JointDistributionCoroutine
def model():
intercept = yield tfd.Normal(loc=0.0, scale=1.0, name="intercept")
slope = yield tfd.Normal(loc=0.0, scale=1.0, name="slope")
mean = tfd.Deterministic(intercept + slope * feature, name="mean")
yield tfd.Normal(loc=mean, scale=1.0, name="response")
A call to model.sample() will return a named tuple including the value of mean, conditional on alpha and beta (and feature). However, if we wish to compute the log probability density of the model given response, intercept, and slope, we also have to pass into model.log_prob a value of mean. Here, mean must be consistent with intercept and slope, which requires the user to duplicate the expression for mean outside the model object. e.g.
intercept = 0.1
slope = 0.2
feature = 0.5
response = 0.21
# Since `mean` is deterministic, we should not have to re-compute it outside of `model`
mean = intercept + slope * feature
lp = model.log_prob(intercept=intercept, slope=slope, mean=mean, response=response)
This seems wasteful in terms of keystrokes, but also error-prone if model changes.
Suggested solution
A potential solution would be to include a sub-class similar to JointDistribution.Root called JointDistribution.Trace which would flag an expression for tracing in the forward generating process (i.e. model.sample()), but exclude the associated variable from the CDF/CMF and PDF/PMF-related methods. Thus we could write:
@tfd.JointDistributionCoroutine
def model():
intercept = yield tfd.Normal(loc=0.0, scale=1.0, name="intercept")
slope = yield tfd.Normal(loc=0.0, scale=1.0, name="slope")
mean =Trace(intercept + slope * feature, name="mean")
yield tfd.Normal(loc=mean, scale=1.0, name="response")
draw = model.sample(seed=[0,0])
# `mean` is simply ignored
model.log_prob(draw)
# `mean` does not have to be supplied
model.log_prob(intercept=draw.intercept, slope=draw.slope, response=draw.response)
Does this seem like a feasible addition? (I may have some resource to devote to it)
- 主要言語
- Jupyter Notebook
- スター
- 4.4k
- フォーク
- 1.1k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
tensorflow/probability のほかの issue
-
KL divergence between two `TransformedDistribution`s with a shared non-injective bijector (`AbsoluteValue`) returns the base KL対応中かも @Andreas-Hum が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
tensorflow/probability#2036 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
tensorflow/probability#2034 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
tensorflow/probability#2021 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
tensorflow/probability#2015 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
tensorflow/probability#2013 ·
tensorflow/probability の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
vllm-project/vllm-ascend#21392 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
type:epic-wave
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
jejjohnson/filterax#204 ·
メンテナーはふだん 1 日以内に返信
-
documentation good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
selimfirat/pysad#644 ·
メンテナーはふだん 1 日以内に返信