Skip to content

Commit

Permalink
07/18/2013 #1 fix C C++ Java Scala
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuke Sugomori committed Jul 18, 2013
1 parent cbd7833 commit 2d9d06d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion c/DBN.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ void RBM_contrastive_divergence(RBM* this, int *input, double lr, int k) {

for(i=0; i<this->n_hidden; i++) {
for(j=0; j<this->n_visible; j++) {
this->W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / this->N;
// this->W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / this->N;
this->W[i][j] += lr * (ph_mean[i] * input[j] - nh_means[i] * nv_samples[j]) / this->N;
}
this->hbias[i] += lr * (ph_sample[i] - nh_means[i]) / this->N;
}
Expand Down
3 changes: 2 additions & 1 deletion c/RBM.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ void RBM_contrastive_divergence(RBM* this, int *input, double lr, int k) {

for(i=0; i<this->n_hidden; i++) {
for(j=0; j<this->n_visible; j++) {
this->W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / this->N;
// this->W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / this->N;
this->W[i][j] += lr * (ph_mean[i] * input[j] - nh_means[i] * nv_samples[j]) / this->N;
}
this->hbias[i] += lr * (ph_sample[i] - nh_means[i]) / this->N;
}
Expand Down
3 changes: 2 additions & 1 deletion cpp/DBN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ void RBM::contrastive_divergence(int *input, double lr, int k) {

for(int i=0; i<n_hidden; i++) {
for(int j=0; j<n_visible; j++) {
W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
// W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
W[i][j] += lr * (ph_mean[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
}
hbias[i] += lr * (ph_sample[i] - nh_means[i]) / N;
}
Expand Down
3 changes: 2 additions & 1 deletion cpp/RBM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ void RBM::contrastive_divergence(int *input, double lr, int k) {

for(int i=0; i<n_hidden; i++) {
for(int j=0; j<n_visible; j++) {
W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
// W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
W[i][j] += lr * (ph_mean[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
}
hbias[i] += lr * (ph_sample[i] - nh_means[i]) / N;
}
Expand Down
3 changes: 2 additions & 1 deletion java/DBN/src/RBM.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public void contrastive_divergence(int[] input, double lr, int k) {

for(int i=0; i<n_hidden; i++) {
for(int j=0; j<n_visible; j++) {
W[i][j] += lr *(ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
// W[i][j] += lr *(ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
W[i][j] += lr *(ph_mean[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
}
hbias[i] += lr * (ph_sample[i] - nh_means[i]) / N;
}
Expand Down
3 changes: 2 additions & 1 deletion java/RBM/src/RBM.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public void contrastive_divergence(int[] input, double lr, int k) {

for(int i=0; i<n_hidden; i++) {
for(int j=0; j<n_visible; j++) {
W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
// W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
W[i][j] += lr * (ph_mean[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
}
hbias[i] += lr * (ph_sample[i] - nh_means[i]) / N;
}
Expand Down
3 changes: 2 additions & 1 deletion scala/RBM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class RBM(val N: Int, val n_visible: Int, val n_hidden: Int,
var j: Int = 0
for(i <- 0 until n_hidden) {
for(j <- 0 until n_visible) {
W(i)(j) += lr * (ph_sample(i) * input(j) - nh_means(i) * nv_samples(j)) / N
// W(i)(j) += lr * (ph_sample(i) * input(j) - nh_means(i) * nv_samples(j)) / N
W(i)(j) += lr * (ph_mean(i) * input(j) - nh_means(i) * nv_samples(j)) / N
}
hbias(i) += lr * (ph_sample(i) - nh_means(i)) / N
}
Expand Down

0 comments on commit 2d9d06d

Please sign in to comment.