當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。