Skip to content
Snippets Groups Projects
Commit 7fdfc57a authored by SebastianBruijns's avatar SebastianBruijns
Browse files

real fix

parent adb52a7a
No related branches found
No related tags found
No related merge requests found
...@@ -111,13 +111,13 @@ class Categorical(GibbsSampling, MeanField, MeanFieldSVI, MaxLikelihood, MAP): ...@@ -111,13 +111,13 @@ class Categorical(GibbsSampling, MeanField, MeanFieldSVI, MaxLikelihood, MAP):
self.weights = np.random.dirichlet(self.alphav_0 + counts) self.weights = np.random.dirichlet(self.alphav_0 + counts)
except ZeroDivisionError as e: except ZeroDivisionError as e:
# print("ZeroDivisionError {}".format(e)) # print("ZeroDivisionError {}".format(e))
self.weights = np.random.dirichlet(self.alphav_0 + 0.03 + counts) self.weights = np.random.dirichlet(self.alphav_0 + 0.01 + counts)
except ValueError as e: except ValueError as e:
# print("ValueError {}".format(e)) # print("ValueError {}".format(e))
self.weights = np.random.dirichlet(self.alphav_0 + 0.03 + counts) self.weights = np.random.dirichlet(self.alphav_0 + 0.01 + counts)
if np.isnan(self.weights).any(): if np.isnan(self.weights).any():
self.weights = np.random.dirichlet(self.alphav_0 + 0.03 + counts) self.weights = np.random.dirichlet(self.alphav_0 + 0.01 + counts)
np.clip(self.weights, np.spacing(1.), np.inf, out=self.weights) np.clip(self.weights, np.spacing(1.), 1-np.spacing(1.), out=self.weights)
# NOTE: next line is so we can use Gibbs sampling to initialize mean field # NOTE: next line is so we can use Gibbs sampling to initialize mean field
self._alpha_mf = self.weights * self.alphav_0.sum() self._alpha_mf = self.weights * self.alphav_0.sum()
assert (self._alpha_mf >= 0.).all() assert (self._alpha_mf >= 0.).all()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment