def _ulogprob_hid(self, Y, num_is_samples=100):
		"""
		Estimates the unnormalized marginal log-probabilities of hidden states.
		
		Use this method only if you know what you are doing.
		"""

		# approximate this SRBM with an RBM
		rbm = RBM(self.X.shape[0], self.Y.shape[0])
		rbm.W = self.W
		rbm.b = self.b
		rbm.c = self.c

		# allocate memory
		Q = np.asmatrix(np.zeros([num_is_samples, Y.shape[1]]))

		for k in range(num_is_samples):
			# draw importance samples
			X = rbm.backward(Y)

			# store importance weights
			Q[k, :] = self._ulogprob(X, Y) - rbm._clogprob_vis_hid(X, Y)

		# average importance weights to get estimates
		return utils.logmeanexp(Q, 0)
Exemple #2
0
    def _ulogprob_hid(self, Y, num_is_samples=100):
        """
		Estimates the unnormalized marginal log-probabilities of hidden states.
		
		Use this method only if you know what you are doing.
		"""

        # approximate this SRBM with an RBM
        rbm = RBM(self.X.shape[0], self.Y.shape[0])
        rbm.W = self.W
        rbm.b = self.b
        rbm.c = self.c

        # allocate memory
        Q = np.asmatrix(np.zeros([num_is_samples, Y.shape[1]]))

        for k in range(num_is_samples):
            # draw importance samples
            X = rbm.backward(Y)

            # store importance weights
            Q[k, :] = self._ulogprob(X, Y) - rbm._clogprob_vis_hid(X, Y)

        # average importance weights to get estimates
        return utils.logmeanexp(Q, 0)