Skip to content

Commit 2d9d06d

Browse files
author
Yusuke Sugomori
committed
07/18/2013 yusugomori#1 fix C C++ Java Scala
1 parent cbd7833 commit 2d9d06d

File tree

7 files changed

+14
-7
lines changed

7 files changed

+14
-7
lines changed

c/DBN.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ void RBM_contrastive_divergence(RBM* this, int *input, double lr, int k) {
347347

348348
for(i=0; i<this->n_hidden; i++) {
349349
for(j=0; j<this->n_visible; j++) {
350-
this->W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / this->N;
350+
// this->W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / this->N;
351+
this->W[i][j] += lr * (ph_mean[i] * input[j] - nh_means[i] * nv_samples[j]) / this->N;
351352
}
352353
this->hbias[i] += lr * (ph_sample[i] - nh_means[i]) / this->N;
353354
}

c/RBM.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ void RBM_contrastive_divergence(RBM* this, int *input, double lr, int k) {
100100

101101
for(i=0; i<this->n_hidden; i++) {
102102
for(j=0; j<this->n_visible; j++) {
103-
this->W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / this->N;
103+
// this->W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / this->N;
104+
this->W[i][j] += lr * (ph_mean[i] * input[j] - nh_means[i] * nv_samples[j]) / this->N;
104105
}
105106
this->hbias[i] += lr * (ph_sample[i] - nh_means[i]) / this->N;
106107
}

cpp/DBN.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ void RBM::contrastive_divergence(int *input, double lr, int k) {
322322

323323
for(int i=0; i<n_hidden; i++) {
324324
for(int j=0; j<n_visible; j++) {
325-
W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
325+
// W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
326+
W[i][j] += lr * (ph_mean[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
326327
}
327328
hbias[i] += lr * (ph_sample[i] - nh_means[i]) / N;
328329
}

cpp/RBM.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ void RBM::contrastive_divergence(int *input, double lr, int k) {
8989

9090
for(int i=0; i<n_hidden; i++) {
9191
for(int j=0; j<n_visible; j++) {
92-
W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
92+
// W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
93+
W[i][j] += lr * (ph_mean[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
9394
}
9495
hbias[i] += lr * (ph_sample[i] - nh_means[i]) / N;
9596
}

java/DBN/src/RBM.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public void contrastive_divergence(int[] input, double lr, int k) {
9191

9292
for(int i=0; i<n_hidden; i++) {
9393
for(int j=0; j<n_visible; j++) {
94-
W[i][j] += lr *(ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
94+
// W[i][j] += lr *(ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
95+
W[i][j] += lr *(ph_mean[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
9596
}
9697
hbias[i] += lr * (ph_sample[i] - nh_means[i]) / N;
9798
}

java/RBM/src/RBM.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public void contrastive_divergence(int[] input, double lr, int k) {
9191

9292
for(int i=0; i<n_hidden; i++) {
9393
for(int j=0; j<n_visible; j++) {
94-
W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
94+
// W[i][j] += lr * (ph_sample[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
95+
W[i][j] += lr * (ph_mean[i] * input[j] - nh_means[i] * nv_samples[j]) / N;
9596
}
9697
hbias[i] += lr * (ph_sample[i] - nh_means[i]) / N;
9798
}

scala/RBM.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ class RBM(val N: Int, val n_visible: Int, val n_hidden: Int,
8686
var j: Int = 0
8787
for(i <- 0 until n_hidden) {
8888
for(j <- 0 until n_visible) {
89-
W(i)(j) += lr * (ph_sample(i) * input(j) - nh_means(i) * nv_samples(j)) / N
89+
// W(i)(j) += lr * (ph_sample(i) * input(j) - nh_means(i) * nv_samples(j)) / N
90+
W(i)(j) += lr * (ph_mean(i) * input(j) - nh_means(i) * nv_samples(j)) / N
9091
}
9192
hbias(i) += lr * (ph_sample(i) - nh_means(i)) / N
9293
}

0 commit comments

Comments
 (0)