From 86181def75f68ad56d8055cab82ed6d22f94df29 Mon Sep 17 00:00:00 2001 From: Fot_St Date: Thu, 16 Apr 2020 04:26:24 +0300 Subject: [PATCH] fix tf.reverse at backward for tensorflow v1.x --- HiddenMarkovModel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HiddenMarkovModel.py b/HiddenMarkovModel.py index 31b74c0..67b58d6 100644 --- a/HiddenMarkovModel.py +++ b/HiddenMarkovModel.py @@ -189,7 +189,7 @@ def _backward(self, obs_prob_list): # Update backward matrix self.backward = tf.scatter_update(self.backward, step+1, self.scale[self.N-2-step] * backward_prob) - self.backward = tf.assign(self.backward, tf.reverse(self.backward, [True, False])) + self.backward = tf.assign(self.backward, tf.reverse(self.backward, [0])) def _posterior(self): @@ -277,7 +277,7 @@ def forward_backward(self, obs_prob_seq): # forward belief propagation self._forward(obs_prob_list_for) - obs_prob_seq_rev = tf.reverse(obs_prob_seq, [True, False]) + obs_prob_seq_rev = tf.reverse(obs_prob_seq, [0]) obs_prob_list_back = tf.split(obs_prob_seq_rev, self.N, 0) with tf.name_scope('backward_belief_propagation'):