当前位置: 首页>>代码示例>>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;未经允许,请勿转载。