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


Python RBM.save_weights方法代碼示例

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


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

示例1: print

# 需要導入模塊: from rbm import RBM [as 別名]
# 或者: from rbm.RBM import save_weights [as 別名]
print('DBN')

rbm1 = RBM(inputData[0].shape[0], 900, ['rbmw1', 'rbvb1', 'rbmhb1'], 0.3)
rbm2 = RBM(900, 500, ['rbmw2', 'rbvb2', 'rbmhb2'], 0.3)
epoch = 1

# Train First RBM
print('first rbm')

for g in range(epoch):
    for it in range(len(inputData)):
        trX = inputData[it][np.newaxis]
        rbm1.partial_fit(trX)
        print(rbm1.compute_cost(trX))
    print(rbm1.compute_cost(trX))
rbm1.save_weights('./rbmw1.chp')

# Train Second RBM2
print('second rbm')

for g in range(epoch):
    for it in range(len(inputData)):
        trX = inputData[it][np.newaxis]
        # Transform features with first rbm for second rbm
        trX = rbm1.transform(trX)
        rbm2.partial_fit(trX)
        print(rbm2.compute_cost(trX))
    print(rbm2.compute_cost(trX))
rbm2.save_weights('./rbmw2.chp')

print("Training Complete")
開發者ID:abdelrahmanhosny,項目名稱:DL-Cerevesiae,代碼行數:33,代碼來源:dbnModel_2Layers.py

示例2: RBM

# 需要導入模塊: from rbm import RBM [as 別名]
# 或者: from rbm.RBM import save_weights [as 別名]
rbm3 = RBM(500, 250, ['rbmw3', 'rbvb3', 'rbmhb3'], 0.3)
rbm4 = RBM(250, 2,   ['rbmw4', 'rbvb4', 'rbmhb4'], 0.3)

epoch = 1

# Train First RBM
print('first rbm')

for g in range(epoch):
    for it in range(len(inputData)):
        trX = inputData[it][np.newaxis]
        rbm1.partial_fit(trX)
        print(rbm1.compute_cost(trX))
    print(rbm1.compute_cost(trX))
    #show_image("1rbm.jpg", rbm1.n_w, (28, 28), (30, 30))
rbm1.save_weights('./rbmw1.chp')

# Train Second RBM2
print('second rbm')

for g in range(epoch):
    for it in range(len(inputData)):
        trX = inputData[it][np.newaxis]
        # Transform features with first rbm for second rbm
        trX = rbm1.transform(trX)
        rbm2.partial_fit(trX)
        print(rbm2.compute_cost(trX))
    print(rbm2.compute_cost(trX))
    #show_image("2rbm.jpg", rbmobject2.n_w, (30, 30), (25, 20))
rbm2.save_weights('./rbmw2.chp')
開發者ID:abdelrahmanhosny,項目名稱:DL-Cerevesiae,代碼行數:32,代碼來源:dbnModel_4Layers.py

示例3: AutoEncoder

# 需要導入模塊: from rbm import RBM [as 別名]
# 或者: from rbm.RBM import save_weights [as 別名]
autoencoder = AutoEncoder(784, [900, 500, 250, 2], [['rbmw1', 'rbmhb1'],
                                                    ['rbmw2', 'rbmhb2'],
                                                    ['rbmw3', 'rbmhb3'],
                                                    ['rbmw4', 'rbmhb4']], tied_weights=False)

iterations = len(trX) / FLAGS.batchsize

# Train First RBM
print('first rbm')
for i in range(FLAGS.epochs):
  for j in range(iterations):
    batch_xs, batch_ys = mnist.train.next_batch(FLAGS.batchsize)
    rbmobject1.partial_fit(batch_xs)
  print(rbmobject1.compute_cost(trX))
  show_image("out/1rbm.jpg", rbmobject1.n_w, (28, 28), (30, 30))
rbmobject1.save_weights('./out/rbmw1.chp')

# Train Second RBM2
print('second rbm')
for i in range(FLAGS.epochs):
  for j in range(iterations):
    batch_xs, batch_ys = mnist.train.next_batch(FLAGS.batchsize)
    # Transform features with first rbm for second rbm
    batch_xs = rbmobject1.transform(batch_xs)
    rbmobject2.partial_fit(batch_xs)
  print(rbmobject2.compute_cost(rbmobject1.transform(trX)))
  show_image("out/2rbm.jpg", rbmobject2.n_w, (30, 30), (25, 20))
rbmobject2.save_weights('./out/rbmw2.chp')

# Train Third RBM
print('third rbm')
開發者ID:Cospel,項目名稱:rbm-ae-tf,代碼行數:33,代碼來源:test-ae-rbm.py


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