view sandbox/rbm/main.py @ 419:43d9aa93934e

added other_ops.py to nnet_ops; added basic tests, no docs.
author James Bergstra <bergstrj@iro.umontreal.ca>
date Mon, 14 Jul 2008 16:48:02 -0400
parents c2e6a8fcc35e
children
line wrap: on
line source

#!/usr/bin/python
"""
Simple SGD RBM training.
(An example of how to use the model.)
"""


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(input_dimension=10, hidden_dimension=6)

for i in xrange(100000):
    # Select an instance
    instance = nonzero_instances[i % len(nonzero_instances)]

    # SGD update over instance
    model.update([instance])