comparison simple_autoassociator/main.py @ 389:ec8aadb6694d

Renamed simple AA directory
author Joseph Turian <turian@gmail.com>
date Tue, 08 Jul 2008 17:41:45 -0400
parents simple_autoassociator.py/main.py@98ca97cc9910
children e2cb8d489908
comparison
equal deleted inserted replaced
388:98ca97cc9910 389:ec8aadb6694d
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)