当前位置: 首页>>代码示例>>Python>>正文


Python RBM.sample_h_given_v方法代码示例

本文整理汇总了Python中rbm.RBM.sample_h_given_v方法的典型用法代码示例。如果您正苦于以下问题:Python RBM.sample_h_given_v方法的具体用法?Python RBM.sample_h_given_v怎么用?Python RBM.sample_h_given_v使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rbm.RBM的用法示例。


在下文中一共展示了RBM.sample_h_given_v方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pretrain_rbm_layers

# 需要导入模块: from rbm import RBM [as 别名]
# 或者: from rbm.RBM import sample_h_given_v [as 别名]
def pretrain_rbm_layers(v, validation_v=None, n_hidden=[], gibbs_steps=[], batch_size=[], num_epochs=[], learning_rate=[], probe_epochs=[]):
    rbm_layers = []
    n_rbm = len(n_hidden)
    # create rbm layers
    for i in range(n_rbm):
        rbm = RBM(n_hidden=n_hidden[i],
                    gibbs_steps=gibbs_steps[i],
                    batch_size=batch_size[i],
                    num_epochs=num_epochs[i],
                    learning_rate=learning_rate[i],
                    probe_epochs=probe_epochs[i])
        rbm_layers.append(rbm)
    # pretrain rbm layers
    input = v
    validation_input = validation_v
    for rbm, i in zip(rbm_layers, range(len(rbm_layers))):
        print '### pretraining RBM Layer {i}'.format(i=i)
        rbm.fit(input, validation_input)
        output = rbm.sample_h_given_v(input, rbm.params['W'], rbm.params['c'])
        if validation_input is not None:
            validation_output = rbm.sample_h_given_v(validation_input, rbm.params['W'], rbm.params['c'])
        else:
            validation_output = None
        input = output
        validation_input = validation_output
    return rbm_layers
开发者ID:taiqing,项目名称:tensorflowNN,代码行数:28,代码来源:dbn_no_finetune.py

示例2: range

# 需要导入模块: from rbm import RBM [as 别名]
# 或者: from rbm.RBM import sample_h_given_v [as 别名]
        for y in range(0,len(data[x])):
            new_data[y] += data[x][y]
    new_data = [x / len(data[0]) for x in new_data]
    return new_data



n_hidden = 500
n_visable = 28 * 28
x = T.matrix('x')
datasets = load_data('mnist.pkl.gz')
train_set_x, train_set_y = datasets[0]
test_set_x, test_set_y = datasets[2]
rng = numpy.random.RandomState(123)
theano_rng = RandomStreams(rng.randint(2 ** 30))
rbm = RBM(input=x, n_visible=28 * 28,
              n_hidden=n_hidden, numpy_rng=rng, theano_rng=theano_rng)
# train_rbm(rbm, datasets[0], learning_rate=0.1, training_epochs=5,
#               batch_size=20, output_folder='rbm_plots', n_hidden=500, CD_steps=2)
# sample_rbm(rbm=None, test_set_x=test_set_x, x=1, n_samples=500, n_step=1,percentage_noise=5, n_repeat=10)

# print(test_set_x.get_value(borrow=True)[0])

# single = theano.shared(
#         numpy.asarray(
#             test_set_x.get_value(borrow=True),
#             dtype=theano.config.floatX
#         )
#     )
l = rbm.sample_h_given_v(test_set_x)
print(l[-1].eval())
开发者ID:sookool99,项目名称:audo-file-detection,代码行数:33,代码来源:main.py


注:本文中的rbm.RBM.sample_h_given_v方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。