Mercurial > pylearn
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sandbox/rbm/main.py Tue Jul 08 20:14:21 2008 -0400 @@ -0,0 +1,28 @@ +#!/usr/bin/python +""" + An RBM with binomial units trained with CD-1. + + LIMITATIONS: + - Only does pure stochastic gradient (batchsize = 1). +""" + + +import numpy + +nonzero_instances = [] +nonzero_instances.append({0: 1, 1: 1}) +nonzero_instances.append({0: 1, 2: 1}) + +#nonzero_instances.append({1: 0.1, 5: 0.5, 9: 1}) +#nonzero_instances.append({2: 0.3, 5: 0.5, 8: 0.8}) +##nonzero_instances.append({1: 0.2, 2: 0.3, 5: 0.5}) + +import model +model = model.Model() + +for i in xrange(100000): + # Select an instance + instance = nonzero_instances[i % len(nonzero_instances)] + + # SGD update over instance + model.update(instance)