Skip to content

Commit

Permalink
set log-potentials to -infinity instead of zero
Browse files Browse the repository at this point in the history
  • Loading branch information
remilepriol committed Jan 3, 2017
1 parent 120f951 commit bbf2f74
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions IsingModel/Ising2.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,12 @@ def loopybelief(self, max_iter=25):
# 4 : log-potentials in each point
# potentials are stored in an additional channel
messages[4] = self.__repeat_symmetric(self.linear_factors)
# if +1 is observed, set potential for -1 to 0
messages[4, :, :, 1] = (1-(self.observations == 1)) * messages[4, :, :, 1]
# if -1 is observed, set potential for +1 to 0
messages[4, :,:, 0] = (1-(self.observations == -1)) * messages[4, :, :, 1]
# if +1 is observed, set potential for -1 to -infinity
messages[4, :, :, 1] = (1 - (self.observations == 1)) * messages[4, :, :, 1] + \
float('-inf') * (self.observations == 1)
# if -1 is observed, set potential for +1 to -infinity
messages[4, :, :, 0] = (1 - (self.observations == -1)) * messages[4, :, :, 0] + \
float('-inf') * (self.observations == -1)

upper = messages[:, :-1, :]
lower = messages[:, 1:, :]
Expand Down

0 comments on commit bbf2f74

Please sign in to comment.