Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hmm step prediction #1295

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
return categorical distribution
  • Loading branch information
hendriksanta committed Apr 7, 2021
commit 86bd350ae6724378426c9b63b6b0a3d4ddf57d0e
Original file line number Diff line number Diff line change
@@ -1196,21 +1196,21 @@ def single_step_prediction(self, observation, prediction_distribution=None, init
if not isinstance(initialisation_step, bool):
raise TypeError('initialisation_step must be of type bool, but saw: %s' % initialisation_step)

if(initialisation_step):
if (initialisation_step):
num = self.initial_distribution.log_prob(range(self.num_states_static)) \
+ self.observation_distribution.log_prob(observation)
else:
if not isinstance(prediction_distribution, distribution.Distribution):
raise TypeError('If initialisation_step is False, then current prediction distribution must be provided.'
'prediction_distribution must be a Distribution instance, but saw: %s' %
prediction_distribution)
num = tf.math.log(prediction_distribution) \
num = tf.math.log(prediction_distribution.probs) \
+ self.observation_distribution.log_prob(observation)

filtering_distribution = tf.exp(num - tf.reduce_logsumexp(num))
prediction_distribution = tf.tensordot(self.transition_distribution.probs_parameter(),
filtering_distribution, axes=1)
observation_prediction = tf.tensordot(prediction_distribution, self.observation_distribution.mean(), axes=1)
prediction_distribution = categorical.Categorical(probs=tf.tensordot(self.transition_distribution.probs_parameter(),
filtering_distribution, axes=1))
observation_prediction = tf.tensordot(prediction_distribution.probs, self.observation_distribution.mean(), axes=1)

return prediction_distribution, observation_prediction