1 """
2 Defines CFSOM, a sheet class that works like a Kohonen SOM extended to
3 support topographically restricted receptive fields.
4
5 $Id: cfsom.py 5636 2007-04-25 04:14:53Z jbednar $
6 """
7 __version__='$Revision: 5636 $'
8
9 from numpy.oldnumeric import argmax,exp,floor
10
11 from topo.base.arrayutils import L2norm
12 from topo.base.parameterclasses import Number
13 from topo.base.cf import CFSheet
14 from topo.learningfns.som import CFPLF_SOM
15
16
17
18
20 """
21 Kohonen Self-Organizing Map algorithm extended to support ConnectionFields.
22
23 This is an implementation of the Kohonen SOM algorithm extended to
24 support ConnectionFields, i.e., different spatially restricted
25 input regions for different units. With fully connected input
26 regions, it should be usable as a regular SOM as well.
27
28 This implementation is obsolete and will be removed soon.
29 Please see examples/cfsom_or.ty for current SOM support.
30 """
31 alpha_0 = Number(0.5, doc="Initial value of the learning rate.")
32 radius_0 = Number(1.0, doc="Initial value of the neighborhood radius.")
33 precedence = Number(0.6)
34 learning_length = Number(1000, doc="Number of input presentations to use, by default.")
35
40
41 - def decay(self, time, half_life):
42 """Exponential decay."""
43 return 0.5**(time/float(half_life))
44
46 """Return the learning rate at a specified simulation time, using exponential falloff."""
47 return self.alpha_0 * self.decay(float(self.simulation.time()),self.half_life)
48
50 """Return the radius at a specified simulation time, using exponential falloff."""
51 return self.radius_0 * self.decay(float(self.simulation.time()),self.half_life)
52
64