Mercurial > pylearn
comparison sandbox/rbm/main.py @ 395:70019965f888
Basic, broken RBM implementation
author | Joseph Turian <turian@gmail.com> |
---|---|
date | Tue, 08 Jul 2008 20:14:21 -0400 |
parents | sandbox/simple_autoassociator/main.py@36baeb7125a4 |
children | 8796b91a9f09 |
comparison
equal
deleted
inserted
replaced
394:f2d112dc53be | 395:70019965f888 |
---|---|
1 #!/usr/bin/python | |
2 """ | |
3 An RBM with binomial units trained with CD-1. | |
4 | |
5 LIMITATIONS: | |
6 - Only does pure stochastic gradient (batchsize = 1). | |
7 """ | |
8 | |
9 | |
10 import numpy | |
11 | |
12 nonzero_instances = [] | |
13 nonzero_instances.append({0: 1, 1: 1}) | |
14 nonzero_instances.append({0: 1, 2: 1}) | |
15 | |
16 #nonzero_instances.append({1: 0.1, 5: 0.5, 9: 1}) | |
17 #nonzero_instances.append({2: 0.3, 5: 0.5, 8: 0.8}) | |
18 ##nonzero_instances.append({1: 0.2, 2: 0.3, 5: 0.5}) | |
19 | |
20 import model | |
21 model = model.Model() | |
22 | |
23 for i in xrange(100000): | |
24 # Select an instance | |
25 instance = nonzero_instances[i % len(nonzero_instances)] | |
26 | |
27 # SGD update over instance | |
28 model.update(instance) |