项目作者: aby2s

项目描述 :
Simple Restricted Boltzmann Machine implementation with TensorFlow.
高级语言: Python
项目地址: git://github.com/aby2s/harmonium.git
创建时间: 2017-07-08T16:49:48Z
项目社区:https://github.com/aby2s/harmonium

开源协议:Apache License 2.0

下载


Harmonium

Simple Restricted Boltzmann Machine implementation with TensorFlow.
Implementation supports sigmoid, relu and linear visible/hidden units, l1/l2/sparsity regularization, contrastive divergence and stochastic maximum likelihood learning (sml/pcd) with momentum.

Writing a Simple RBM

  1. # Here is a simple code sample
  2. # See harmonium/rbm.py for an API documentation
  3. # You can also find full MNIST example under examples folder
  4. train_set, valid_set, test_set = load_mnist('.//data')
  5. n_hidden = 100
  6. n_visible = 784
  7. rbm = RBMModel(visible=RBMLayer(activation='linear', units=n_visible, use_bias=True, sampled=False), hidden=RBMLayer(activation='sigmoid', units=n_hidden, use_bias=True, sampled=True))
  8. rbm.compile(cd(1, lr=1e-2), unstack=True, kernel_regularizer=l1(0.00001))
  9. rbm.fit(train_set, batch_size=256, nb_epoch=20, verbose=1)
  10. valid_set_reconstruction = rbm.generate(valid_set, sampled=False, n=1)

harmonium/rbm_utils.py contains some simple utilities to explore RBM weights.
save_weights function saves weights as separate maps for every hidden neuron. For grayscale RBM images it should print set of learned features.
save_hidden_state function saves changes in hidden states across a set of samples. For well-trained RBM it shouldn’t contain continous white or black lines.

Installation

  1. git clone https://github.com/aby2s/harmonium.git
  2. cd harmonium
  3. python setup.py install

Release notes

Version 0.0.2

  • Renamed to harmonium
  • Manual gradient calculation changed to tensorflow optimizers with stop_gradient applied on rbm states
  • Added PCD optimizer

    Version 0.0.1

  • Initial release

Contacts

Create an issue or send me an email (aby2sz@gmail.com).