som.py
def update(self, sample):
        '''
        if the whole map has been initialized - do SOM step
        else use the new sample as a prototype.
        the SOM step is divided such that the new error is first computed 
        and the error condition is checked before the update. if the error condition yeilds True,
        initial parameters are restarted according to the policy selected 
        at the initialization of the class object.
        '''
        sample = sample.astype('float64')
        
        if self.iteration%100==0:
            self.maps_log[str(self.iteration)]=np.copy(self.somap.reshape((self.size,self.size,self.dim)))
        
        
        if self.iteration < self.size**2:
            self.somap[self.iteration] = sample
            self.errors.append(0)
            self.err_condition.append(0)
        else:
            self.samples.append(sample)
            min_error = np.min(np.sqrt(np.sum((sample - self.somap)**2, axis=1)))
            if self.iteration > self.size**2 + self.T:    
                if self.error_condition(min_error):
                    self.restart_params()
                    print('parameters restarted at iteration ',self.iteration)
            else:
                self.err_condition.append(0)
            self.errors.append(min_error)
            self._update(sample)

        self.iteration += 1

        if the whole map has been initialized - do SOM step
        else use the new sample as a prototype.
        the SOM step is divided such that the new error is first computed 
        and the error condition is checked before the update. if the error condition yeilds True,
        initial parameters are restarted according to the policy selected 
        at the initialization of the class object.
        
if the whole map has been initialized - do SOM step
else use the new sample as a prototype.
the SOM step is divided such that the new error is first computed
and the error condition is checked before the update. if the error condition yeilds True,
initial parameters are restarted according to the policy selected
at the initialization of the class object.
if the whole map has been initialized - do SOM step else use the new sample as a prototype . the SOM step is divided such that the new error is first computed and the error condition is checked before the update . if the error condition yeilds True initial parameters are restarted according to the policy selected at the initialization of the class object .
def update(self, sample):
        sample = sample.astype('float64')
        if self.iteration%100==0:
            self.maps_log[str(self.iteration)]=np.copy(self.somap.reshape((self.size,self.size,self.dim)))
        if self.iteration < self.size**2:
            self.somap[self.iteration] = sample
            self.errors.append(0)
            self.err_condition.append(0)
        else:
            self.samples.append(sample)
            min_error = np.min(np.sqrt(np.sum((sample - self.somap)**2, axis=1)))
            if self.iteration > self.size**2 + self.T:    
                if self.error_condition(min_error):
                    self.restart_params()
                    print('parameters restarted at iteration ',self.iteration)
            else:
                self.err_condition.append(0)
            self.errors.append(min_error)
            self._update(sample)
        self.iteration += 1
def update ( self , sample ) : sample = sample . astype ( 'float64' ) if self . iteration % 100 == 0 : self . maps_log [ str ( self . iteration ) ] = np . copy ( self . somap . reshape ( ( self . size , self . size , self . dim ) ) ) if self . iteration < self . size ** 2 : self . somap [ self . iteration ] = sample self . errors . append ( 0 ) self . err_condition . append ( 0 ) else : self . samples . append ( sample ) min_error = np . min ( np . sqrt ( np . sum ( ( sample - self . somap ) ** 2 , axis = 1 ) ) ) if self . iteration > self . size ** 2 + self . T : if self . error_condition ( min_error ) : self . restart_params ( ) print ( 'parameters restarted at iteration ' , self . iteration ) else : self . err_condition . append ( 0 ) self . errors . append ( min_error ) self . _update ( sample ) self . iteration += 1
if the whole map has been initialized - do SOM step
else use the new sample as a prototype.
if the whole map has been initialized - do SOM step else use the new sample as a prototype .
'''
        if the whole map has been initialized - do SOM step
        else use the new sample as a prototype.
        the SOM step is divided such that the new error is first computed 
        and the error condition is checked before the update. if the error condition yeilds True,
        initial parameters are restarted according to the policy selected 
        at the initialization of the class object.
        '''
self
sample