當前位置: 首頁>>代碼示例>>Python>>正文


Python RBM.W方法代碼示例

本文整理匯總了Python中rbm.RBM.W方法的典型用法代碼示例。如果您正苦於以下問題:Python RBM.W方法的具體用法?Python RBM.W怎麽用?Python RBM.W使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rbm.RBM的用法示例。


在下文中一共展示了RBM.W方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _ulogprob_hid

# 需要導入模塊: from rbm import RBM [as 別名]
# 或者: from rbm.RBM import W [as 別名]
	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)
開發者ID:Paseam,項目名稱:BackgroundSubtraction_by_GBRBM,代碼行數:27,代碼來源:semirbm.py

示例2: load_dbn_param

# 需要導入模塊: from rbm import RBM [as 別名]
# 或者: from rbm.RBM import W [as 別名]
 def load_dbn_param(self,dbnpath,softmaxpath):
     weights = cPickle.load(open(dbnpath,'rb'))
     vlen,hlen = 0,0
     self.nlayers = len(weights)
     for i in range(self.nlayers):
         weight = weights[i]
         vlen,hlen = weight.shape[0],weight.shape[1]
         rbm = RBM(vlen,hlen)
         rbm.W = weight
         self.rbm_layers.append(rbm)
         print "RBM layer%d shape:%s" %(i,str(rbm.W.shape))
     self.softmax = SoftMax()
     self.softmax.load_theta(softmaxpath)
     print "softmax parameter: "+str(self.softmax.theta.shape)
開發者ID:fanfannothing,項目名稱:MyDBN,代碼行數:16,代碼來源:dbn.py

示例3: xrange

# 需要導入模塊: from rbm import RBM [as 別名]
# 或者: from rbm.RBM import W [as 別名]
        input = rbm3.reconstruct_from_output(input)
        input = rbm2.reconstruct_from_output(input)
        input = rbm1.reconstruct_from_output(input)

        for i in xrange(input.shape[0]):
            first_input = rbm1.input[i]
            last_input = input[i]

            delta = [x-y for(x, y) in zip(first_input, last_input)]
            delta = numpy.array(delta)

            # RBM1 finetune
            W = rbm1.W
            for j in xrange(W.shape[0]):
                W[j] = W[j] + finetuning_lr * delta
            rbm1.W = W
            delta = rbm1.output_from_input(delta)

            # RBM2 finetune
            W = rbm2.W
            for j in xrange(W.shape[0]):
                W[j] = W[j] + finetuning_lr * delta
            rbm2.W = W
            delta = rbm2.output_from_input(delta)

            # RBM3 finetune
            W = rbm3.W
            for j in xrange(W.shape[0]):
                W[j] = W[j] + finetuning_lr * delta
            rbm3.W = W
            delta = rbm3.output_from_input(delta)
開發者ID:hamalab-test,項目名稱:t.nishisaki,代碼行數:33,代碼來源:dbn_finetuning.py


注:本文中的rbm.RBM.W方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。