本文整理汇总了Python中rbm.RBM.train_CD方法的典型用法代码示例。如果您正苦于以下问题:Python RBM.train_CD方法的具体用法?Python RBM.train_CD怎么用?Python RBM.train_CD使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rbm.RBM
的用法示例。
在下文中一共展示了RBM.train_CD方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pretrainRBM
# 需要导入模块: from rbm import RBM [as 别名]
# 或者: from rbm.RBM import train_CD [as 别名]
def pretrainRBM(self,trainset):
trainv = np.mat(trainset[1]) # 1xn
vlen = trainv.shape[1]
trainnum = len(trainset)
hlen = 500
weights = []
print "vlen = %d" %(vlen)
print "Trainnum = %d" %(trainnum)
for i in range(self.nlayers):
rbm = RBM(vlen,hlen)
T,e = 3,0.05
if i == 0:
traindata = trainset
else:
traindata = outdata
outdata = np.zeros((trainnum,hlen))
for j in range(trainnum):
print "layer:%d CD sample %d..." %(i,j)
trainv = np.mat(traindata[j])
rbm.train_CD(trainv,T,e)
outdata[j] = np.mat(rbm.sample(rbm.calc_forward(trainv))) # 1xhlen
self.rbm_layers.append(rbm)
weights.append(rbm.W)
vlen = hlen
# hlen -= 100
dump_data("data/dbn.pkl",weights)
print "========= pretrainRBM complete ==========="