comparison simple_autoassociator.py/main.py @ 386:a474341861fa

Added a simple AA
author Joseph Turian <turian@gmail.com>
date Tue, 08 Jul 2008 02:27:00 -0400
parents sparse_random_autoassociator/main.py@e4473d9697d7
children 98ca97cc9910
comparison
equal deleted inserted replaced
385:db28ff3fb887 386:a474341861fa
1 #!/usr/bin/python
2 """
3 A simple autoassociator.
4
5 The learned model is::
6 h = sigmoid(dot(x, w1) + b1)
7 y = sigmoid(dot(h, w2) + b2)
8
9 Binary xent loss.
10
11 LIMITATIONS:
12 - Only does pure stochastic gradient (batchsize = 1).
13 """
14
15
16 import numpy
17
18 nonzero_instances = []
19 nonzero_instances.append({1: 0.1, 5: 0.5, 9: 1})
20 nonzero_instances.append({2: 0.3, 5: 0.5, 8: 0.8})
21 nonzero_instances.append({1: 0.2, 2: 0.3, 5: 0.5})
22
23 import model
24 model = model.Model()
25
26 for i in xrange(100000):
27 # Select an instance
28 instance = nonzero_instances[i % len(nonzero_instances)]
29
30 # SGD update over instance
31 model.update(instance)