Skip to content

Commit 3563a33

Browse files
author
Yusuke Sugomori
committed
RBM reconstruct
1 parent edf9d0a commit 3563a33

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

RestrictedBoltzmannMachine.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,10 @@ def get_reconstruction_cross_entropy(self):
133133

134134
return cross_entropy
135135

136-
137-
136+
def reconstruct(self, v):
137+
h = sigmoid(numpy.dot(v, self.W) + self.hbias)
138+
reconstructed_v = sigmoid(numpy.dot(h, self.W.T) + self.vbias)
139+
return reconstructed_v
138140

139141

140142
def test_rbm(learning_rate=0.1, k=1, training_epochs=1000):
@@ -159,12 +161,10 @@ def test_rbm(learning_rate=0.1, k=1, training_epochs=1000):
159161

160162

161163
# test
162-
# v = numpy.array([0, 0, 0, 1, 1, 0])
163-
v = numpy.array([1, 1, 0, 0, 0, 0])
164-
h = sigmoid(numpy.dot(v, rbm.W) + rbm.hbias)
164+
v = numpy.array([[0, 0, 0, 1, 1, 0],
165+
[1, 1, 0, 0, 0, 0]])
165166

166-
reconstructed_v = sigmoid(numpy.dot(h, rbm.W.T) + rbm.vbias)
167-
print reconstructed_v
167+
print rbm.reconstruct(v)
168168

169169

170170
if __name__ == "__main__":

0 commit comments

Comments
 (0)