Package topo :: Package learningfn :: Module basic
[hide private]
[frames] | no frames]

Source Code for Module topo.learningfn.basic

  1  """ 
  2  Basic learning functions. 
  3   
  4  $Id: basic.py 11316 2010-07-27 17:52:53Z ceball $ 
  5  """ 
  6  __version__ = "$Revision: 11316 $" 
  7   
  8  import param 
  9   
 10  from topo.base.functionfamily import LearningFn 
 11  # Imported here so that all learning functions will be in the same package 
 12  from topo.base.functionfamily import Hebbian,IdentityLF 
 13   
 14   
 15   
16 -class Oja(LearningFn):
17 """ 18 Oja's rule (Oja, 1982; Dayan and Abbott, 2001, equation 8.16.) 19 20 Hebbian rule with soft multiplicative normalization, tending the 21 weights toward a constant sum-squared value over time. Thus this 22 function does not normally need a separate output_fn for normalization. 23 """ 24 25 alpha=param.Number(default=0.1,bounds=(0,None))
26 - def __call__(self,input_activity, unit_activity, weights, single_connection_learning_rate):
27 weights += single_connection_learning_rate * (unit_activity * input_activity - 28 self.alpha * (unit_activity**2) * weights)
29
30 -class Covariance(LearningFn):
31 """ 32 Covariance learning rule supporting either input or unit thresholds. 33 34 As presented by Dayan and Abbott (2001), covariance rules allow 35 either potentiation or depression of the same synapse, depending 36 on an activity level. By default, this implementation follows 37 Dayan and Abbott equation 8.8, with the unit_threshold determining 38 the level of postsynaptic activity (activity of the target unit), 39 below which LTD (depression) will occur. 40 41 If you wish to use an input threshold as in Dayan and Abbott 42 equation 8.9 instead, set unit_threshold to zero and change 43 input_threshold to some positive value instead. When both 44 thresholds are zero this rule degenerates to the standard Hebbian 45 rule. 46 47 Requires some form of output_fn normalization for stability. 48 """ 49 50 unit_threshold =param.Number(default=0.5,bounds=(0,None), 51 doc="Threshold between LTD and LTP, applied to the activity of this unit.") 52 input_threshold=param.Number(default=0.0,bounds=(0,None), 53 doc="Threshold between LTD and LTP, applied to the input activity.")
54 - def __call__(self,input_activity, unit_activity, weights, single_connection_learning_rate):
55 weights += single_connection_learning_rate * (unit_activity - self.unit_threshold) * (input_activity - self.input_threshold)
56 57
58 -class CPCA(LearningFn):
59 """ 60 CPCA (Conditional Principal Component Analysis) rule. 61 62 (See O'Reilly and Munakata, Computational Explorations in 63 Cognitive Neuroscience, 2000, equation 4.12.) 64 65 Increases each weight in proportion to the product of this 66 neuron's activity, input activity, and connection weights. 67 68 Has built-in normalization, and so does not require output_fn 69 normalization for stability. Intended to be a more biologically 70 plausible version of the Oja rule. 71 72 Submitted by Veldri Kurniawan and Lewis Ng. 73 """ 74
75 - def __call__(self,input_activity, unit_activity, weights, single_connection_learning_rate):
76 """ 77 Update the value of the given weights matrix based on the 78 input_activity matrix (of the same size as the weights matrix), 79 the response of this unit (the unit_activity), and the previous weights 80 matrix governed by a per-connection learning rate. 81 """ 82 83 weights += single_connection_learning_rate * unit_activity * (input_activity - weights);
84 85
86 -class BCMFixed(LearningFn):
87 """ 88 Bienenstock, Cooper, and Munro (1982) learning rule with a fixed threshold. 89 90 (See Dayan and Abbott, 2001, equation 8.12) In the BCM rule, 91 activities change only when there is both pre- and post-synaptic 92 activity. The full BCM rule requires a sliding threshold (see 93 CFPBCM), but this version is simpler and easier to analyze. 94 95 Requires some form of output_fn normalization for stability. 96 """ 97 98 unit_threshold=param.Number(default=0.5,bounds=(0,None),doc="Threshold between LTD and LTP.")
99 - def __call__(self,input_activity, unit_activity, weights, single_connection_learning_rate):
100 weights += single_connection_learning_rate * unit_activity * input_activity * (unit_activity-self.unit_threshold)
101 102 103 104 __all__ = list(set([k for k,v in locals().items() 105 if isinstance(v,type) and issubclass(v,LearningFn)])) 106