Mercurial > pylearn
view simple_autoassociator.py/main.py @ 390:efb797c5efc0
First non-crashing draft of LinearRegression
author | Yoshua Bengio <bengioy@iro.umontreal.ca> |
---|---|
date | Tue, 08 Jul 2008 17:49:44 -0400 |
parents | a474341861fa |
children | 98ca97cc9910 |
line wrap: on
line source
#!/usr/bin/python """ A simple autoassociator. The learned model is:: h = sigmoid(dot(x, w1) + b1) y = sigmoid(dot(h, w2) + b2) Binary xent loss. LIMITATIONS: - Only does pure stochastic gradient (batchsize = 1). """ import numpy nonzero_instances = [] 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)