wrong batch_shape of distribution for observation distribution in HMM
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- python
- Bereich
- machine-learning
Rechercherichtung
Beginne mit dem im Issue gezeigten Verhalten von tfd.Mixture, tfd.MixtureSameFamily und tfd.HiddenMarkovModel in Bezug auf batch_shape und event_shape. Vergleiche die Shapes der Komponenten- und kategorialen Parameter mit den Anforderungen der HMM-Übergangsverteilung. Als erledigt gilt, eine gültige Shape der Beobachtungsverteilung zu identifizieren, die beide verborgenen Zustände repräsentiert, ohne die gemeldeten scalar-batch- oder last-dimension-Fehler zu verursachen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
I got a serial of observations with shape of (N, 1). These observations correspond to two hidden states.
For hidden state 0, I declare the distribution as below:
dis0 = tfd.MixtureSameFamily(
mixture_distribution=tfd.Categorical(probs=[0.4, 0.4, 0.2]), # mixture_distribution=tfd.Categorical(probs=[0.4, 0.4, 0.2])
components_distribution=tfd.Normal(loc=tf.Variable([100.0, 260.0, 180.0], trainable=True), scale=tf.Variable([10.0], trainable=True)) # tfd.Normal(loc=[100, 260, 180], scale=[10, 10, 10])
)
which mean it's a mixed Normal Distribution with three peaks.
For hidden. state 1, I declare the distribution as below:
dis1 = tfd.Normal(loc=tf.Variable(0.0, trainable=True), scale=tf.Variable(40.0, trainable=True))
which means it's a simple Normal Distribution
then I declare the 'observation distribution' as :
observation_distribution = tfd.Mixture(
cat=tfd.Categorical(probs=[0.9, 0.1]), # 对应两个状态的概率
components=[dis_0, dis_1]
)
After running the above code, I got observation_distribution.batch_shape = []
Even if I adjust the code as below:
`dis_swim = tfd.MixtureSameFamily(
mixture_distribution=tfd.Categorical(probs=[[0.4, 0.4, 0.2]]), # mixture_distribution=tfd.Categorical(probs=[0.4, 0.4, 0.2])
components_distribution=tfd.Normal(loc=tf.Variable([100.0, 260.0, 180.0], trainable=True), scale=tf.Variable([10.0], trainable=True)) # tfd.Normal(loc=[100, 260, 180], scale=[10, 10, 10])
)
dis_turn = tfd.Normal(loc=tf.Variable([0.0], trainable=True), scale=tf.Variable([40.0], trainable=True))
print(dis_turn.batch_shape, dis_turn.event_shape)
observation_distribution = tfd.Mixture(
cat=tfd.Categorical(probs=[[0.9, 0.1]]), # 对应两个状态的概率
components=[dis_swim, dis_turn]
)`
I got observation_distribution.batch_shape = [1]
!!!
However, the observation distribution in HMM needs batch_size equals 2 when I definate the HMM model as below:
hmm = tfd.HiddenMarkovModel(
initial_distribution=tfd.Categorical(probs=[0.5, 0.5]),
transition_distribution=tfd.Categorical(probs=[[0.9, 0.1], [0.1, 0.9]]),
observation_distribution=observation_distribution,
num_steps=N)
so I got the error "observation_distribution can't have scalar batches" or "transition_distribution and observation_distribution must agree on last dimension of batch size"
Is there anyone could introduct me to fix my code?
PS: Tensorflow:2.17.0 Tensorflow-probability 0.24.0
- Vorherrschende Sprache
- Jupyter Notebook
- Sterne
- 4.4k
- Forks
- 1.1k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus tensorflow/probability
-
KL divergence between two `TransformedDistribution`s with a shared non-injective bijector (`AbsoluteValue`) returns the base KLEvtl. vergeben @Andreas-Hum hat das vor 9 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
tensorflow/probability#2036 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 54/100
tensorflow/probability#2040 ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
tensorflow/probability#2034 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
tensorflow/probability#2021 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 30/100
tensorflow/probability#2015 ·
Alle Issues in tensorflow/probability
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug z-test-failure
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
torch-spyre/spyre-inference#1598 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Two different inputs get the same XGBoost churn probability in my Flask API—does that mean my model is broken?Evtl. vergeben @github-actions hat das heute übernommen. Offenfaq-proposal
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 85/100
DataTalksClub/faq#571 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
huggingface/transformers#50598 ·
Maintainer antworten meist innerhalb von 1 Tag
-
OODKnowledgeMetric never parses answer letters and divides by zero when all answers are refusalsEvtl. vergeben @davrens101 hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
stanford-crfm/helm#4379 ·