Skip to content

Commit aa841c4

Browse files
minor unsupervised fix
1 parent dfdaeb1 commit aa841c4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

unsupervised_class2/unsupervised.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ def fit_to_input(self, k, learning_rate=0.00001, mu=0.99, reg=10e-10, epochs=200
5757
# # choose Y[0] b/c it's shape 1xD, we want just a D-size vector, not 1xD matrix
5858
# cost = -(t*T.log(Y[0]) + (1 - t)*(T.log(1 - Y[0]))).sum() + reg*(X * X).sum()
5959

60-
cost = -T.log(Y[k]) + reg*(X * X).sum()
60+
cost = -T.log(Y[0,k]) + reg*(X * X).sum()
6161

6262
updates = [
6363
(X, X + mu*dX - learning_rate*T.grad(cost, X)),
6464
(dX, mu*dX - learning_rate*T.grad(cost, X)),
6565
]
6666
train = theano.function(
6767
inputs=[],
68-
outputs=cost,
68+
outputs=[cost, Y],
6969
updates=updates,
7070
)
7171

@@ -74,7 +74,9 @@ def fit_to_input(self, k, learning_rate=0.00001, mu=0.99, reg=10e-10, epochs=200
7474
for i in xrange(epochs):
7575
if i % 1000 == 0:
7676
print "epoch:", i
77-
the_cost = train()
77+
the_cost, out = train()
78+
if i == 0:
79+
print "out.shape:", out.shape
7880
costs.append(the_cost)
7981
# if the_cost < 10:
8082
# break

unsupervised_class2/visualize_features.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ def main(loadfile=None, savefile=None):
4747

4848
if __name__ == '__main__':
4949
# to load a saved file
50-
# main(loadfile='rbm15.npz')
50+
main(loadfile='rbm15.npz')
5151

5252
# to neither load nor save
5353
# main()
5454

5555
# to save a trained unsupervised deep network
56-
main(savefile='rbm15.npz')
56+
# main(savefile='rbm15.npz')

0 commit comments

Comments
 (0)