comparison sandbox/simple_autoassociator/main.py @ 393:36baeb7125a4

Made sandbox directory
author Joseph Turian <turian@gmail.com>
date Tue, 08 Jul 2008 18:46:26 -0400
parents simple_autoassociator/main.py@e2cb8d489908
children 8849eba55520
comparison
equal deleted inserted replaced
392:e2cb8d489908 393:36baeb7125a4
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({0: 1, 1: 1})
20 nonzero_instances.append({0: 1, 2: 1})
21
22 #nonzero_instances.append({1: 0.1, 5: 0.5, 9: 1})
23 #nonzero_instances.append({2: 0.3, 5: 0.5, 8: 0.8})
24 ##nonzero_instances.append({1: 0.2, 2: 0.3, 5: 0.5})
25
26 import model
27 model = model.Model()
28
29 for i in xrange(100000):
30 # Select an instance
31 instance = nonzero_instances[i % len(nonzero_instances)]
32
33 # SGD update over instance
34 model.update(instance)