当前位置: 首页>>代码示例>>Python>>正文


Python MiniSom.train_single_instance方法代码示例

本文整理汇总了Python中minisom.MiniSom.train_single_instance方法的典型用法代码示例。如果您正苦于以下问题:Python MiniSom.train_single_instance方法的具体用法?Python MiniSom.train_single_instance怎么用?Python MiniSom.train_single_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在minisom.MiniSom的用法示例。


在下文中一共展示了MiniSom.train_single_instance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: KuKuModel

# 需要导入模块: from minisom import MiniSom [as 别名]
# 或者: from minisom.MiniSom import train_single_instance [as 别名]
class KuKuModel(Model):
    
      def __init__(self,proprioception_input_length,sensory_input_length,reservoir_size):
            # Build the Reservoir
            tau = .1 # execution timestep for the cortical rate model
            sigma = .001 # intra-reservoir weights
            eps = .1 # learning rate
            som_size = 10*10
            self.sensory_input_length = sensory_input_length
            self.proprioception_input_length = proprioception_input_length
            
            full_reservoir_input_length = proprioception_input_length+som_size
            # Nodes: units, tau, method
            self.reservoir_input = esn.Node((full_reservoir_input_length,), 0, esn._load )
            self.reservoir = esn.Node((reservoir_size,), tau, esn._reservoir )
            self.reservoir_output = esn.Node((som_size,), 0, esn._load )
            
            # Arcs: target, source, weight, eps
            # input from som
            self.d_P  = esn.Arc( self.reservoir, self.reservoir_input, sigma, 0 )
            self.d_P.initConnections( numpy.random.randn, self.reservoir.shape+self.reservoir_input.shape ) # type of init numpy func
            #print d_P.connections

            # recurrent connections intra node
            self.r_P  = esn.Arc( self.reservoir, self.reservoir, sigma, 0 )
            self.r_P.initConnections( numpy.random.randn, self.reservoir.shape+self.reservoir.shape ) # type of init numpy func
            #print r_P.connections

            # input from som
            self.d_out  = esn.Arc( self.reservoir_output, self.reservoir, 0, eps )
            self.d_out.initConnections( numpy.random.randn, self.reservoir_output.shape+self.reservoir.shape ) # type of init numpy func
            #print d_out.connections
                      
            from minisom import MiniSom
            self.som = MiniSom(10, 10, sensory_input_length,sigma=0.3,learning_rate=0.1,normalize=True)
            
            self.previous_som_activation = numpy.zeros((10,10))
          

      def run(self,inp):
          self.som.train_single_instance(inp[:self.sensory_input_length])
          
          self.reservoir_input.update(numpy.append(self.previous_som_activation.flatten().copy(),inp[-self.proprioception_input_length:])) # 3
          self.reservoir.update(self.d_P.read())
          self.reservoir_output.update(self.d_out.read())
          print "error:",self.som.activation_map.flatten()  - self.reservoir_output.state
          self.d_out.learn(self.som.activation_map.flatten()  - self.reservoir_output.state )
          
          self.previous_som_activation = self.som.activation_map.flatten().copy()
开发者ID:dguarino,项目名称:KuKu,代码行数:51,代码来源:model.py


注:本文中的minisom.MiniSom.train_single_instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。