Skip to content

Commit

Permalink
SINGA-9 Add Support for Restricted Boltzman Machine (RBM) model
Browse files Browse the repository at this point in the history
This is to implement RBM in SINGA.
To training RBM models, the Contrastive Divergence (CD) algorithm is implemented.
We have implemented a BPWorker to run the Back-Propagation algorithm. To implement the CD algorithm, we follow the same way
to create a CDWorker whose RunOneBatch function controls the logic of the CD algorithm, including positive phase,
negative phase and computing gradient phase. RBM's layers are different to the layers for feed-forward neural networks,
hence new layers for RBM models are added.
  • Loading branch information
lzjpaul committed Aug 20, 2015
1 parent 6afa895 commit ef4de79
Show file tree
Hide file tree
Showing 11 changed files with 1,133 additions and 72 deletions.
299 changes: 299 additions & 0 deletions examples/rbm/autoencoder.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
name: "deep-big-simple-mlp"
train_steps: 12200
test_steps:100
test_freq:100
disp_freq:20
checkpoint_after: 1000
checkpoint_freq: 1000
checkpoint_path: "examples/rbm/checkpoint/rbm0/checkpoint/step6000-worker0.bin"
checkpoint_path: "examples/rbm/checkpoint/rbm1/checkpoint/step6000-worker0.bin"
checkpoint_path: "examples/rbm/checkpoint/rbm2/checkpoint/step6000-worker0.bin"
checkpoint_path: "examples/rbm/checkpoint/rbm3/checkpoint/step6000-worker0.bin"
alg: kBP
updater{
type: kAdaGrad
learning_rate{
base_lr: 0.01
type: kFixed
}
}

neuralnet {
layer {
name: "data"
type: kShardData
sharddata_conf {
path: "examples/rbm/mnist_train_shard"
batchsize: 1000
}
exclude: kTest
}

layer {
name: "data"
type: kShardData
sharddata_conf {
path: "examples/rbm/mnist_test_shard"
batchsize: 1000
}
exclude: kTrain
}

layer{
name:"mnist"
type: kMnist
srclayers: "data"
mnist_conf {
norm_a: 255
norm_b: 0
}
}

layer{
name: "label"
type: kLabel
srclayers: "data"
}

layer{
name: "fc1"
type: kInnerProduct
srclayers:"mnist"
innerproduct_conf{
num_output: 1000
}
param{
name: "w1"
init{
type: kUniform
low:-0.05
high:0.05
}
}
param{
name: "rb12"
init{
type: kUniform
low: -0.05
high:0.05
}
}
}

layer{
name: "sigmoid1"
type: kSigmoid
srclayers:"fc1"
}
layer{
name: "fc2"
type: kInnerProduct
srclayers:"sigmoid1"
innerproduct_conf{
num_output: 500
}
param{
name: "w2"
init{
type: kUniform
low:-0.05
high:0.05
}
}
param{
name: "rb22"
init{
type: kUniform
low: -0.05
high:0.05
}
}
}

layer{
name: "sigmoid2"
type: kSigmoid
srclayers:"fc2"
}

layer{
name: "fc3"
type: kInnerProduct
srclayers:"sigmoid2"
innerproduct_conf{
num_output: 250
}
param{
name: "w3"
init{
type: kUniform
low:-0.05
high:0.05
}
}
param{
name: "rb32"
init{
type: kUniform
low: -0.05
high:0.05
}
}
}

layer{
name: "sigmoid3"
type: kSigmoid
srclayers:"fc3"
}

layer{
name: "fc4"
type: kInnerProduct
srclayers:"sigmoid3"
innerproduct_conf{
num_output: 30
}
param{
name: "w4"
init{
type: kUniform
low:-0.05
high:0.05
}
}
param{
name: "rb42"
init{
type: kUniform
low: -0.05
high:0.05
}
}
}

layer{
name: "fc5"
type: kInnerProduct
#srclayers:"sigmoid4"
srclayers:"fc4"
innerproduct_conf{
num_output: 250
transpose: true
}
param{
name: "w5"
share_from: "w4"
}
param{
name: "rb41"
init{
type: kUniform
low: -0.05
high:0.05
}
}
}

layer{
name: "sigmoid5"
type: kSigmoid
srclayers:"fc5"
}
layer{
name: "fc6"
type: kInnerProduct
srclayers:"sigmoid5"
innerproduct_conf{
num_output: 500
transpose: true
}
param{
name: "w6"
share_from: "w3"
}
param{
name: "rb31"
init{
type: kUniform
low: -0.05
high:0.05
}
}

}

layer{
name: "sigmoid6"
type: kSigmoid
srclayers:"fc6"
}
layer{
name: "fc7"
type: kInnerProduct
srclayers:"sigmoid6"
innerproduct_conf{
num_output: 1000
transpose: true
}
param{
name: "w7"
share_from: "w2"
}
param{
name: "rb21"
init{
type: kUniform
low: -0.05
high:0.05
}
}

}

layer{
name: "sigmoid7"
type: kSigmoid
srclayers:"fc7"
}
layer{
name: "fc8"
type: kInnerProduct
srclayers:"sigmoid7"
innerproduct_conf{
num_output: 784
transpose: true
}
param{
name: "w8"
share_from: "w1"
}
param{
name: "rb11"
init{
type: kUniform
low: -0.05
high:0.05
}
}

}

layer{
name: "sigmoid8"
type: kSigmoid
srclayers:"fc8"
}

layer{
name: "loss"
type:kEuclideanLoss
srclayers:"sigmoid8"
srclayers:"mnist"
}
}
cluster {
nworker_groups: 1
nserver_groups: 1
workspace: "examples/rbm/checkpoint/autoencoder/"
}
Loading

0 comments on commit ef4de79

Please sign in to comment.