code: def numenta(self, X, Y):
      r
      batchSize    = len(X)
      W            = self.connections.visible_to_hidden
      n, m         = W.shape
      bias         = self.connections.hidden_bias
      incr         = self.weight_incr
      decr         = self.weight_decr
      boost_bias   = self.boost_strength_bias
      alpha        = self.average_activity
  
      #---------------------------
      # visible-to-hidden updates
      #---------------------------
      for i in range(batchSize):
          y     = Y[i]
          x     = X[i]
          x_bar = np.ones(m) - x   
  
          # Hebbian-like update
          W[ np.where(y == 1)[0] ] += incr*x - decr*x_bar 
  
  
      # Clip the visible-to-hidden connections 
      # to be between $0$ and $1$ 
      tooSmall = np.where(W < 0.)
      tooBig   = np.where(W > 1.)
      W[ tooSmall ] = 0.
      W[ tooBig   ] = 1.
  
  
      #---------------
      # (Hidden) Bias
      #---------------
      for i in range(n):
          bias[i] = boost_bias * alpha[i,i]
docs: r"""
      Method that updates the network's connections. 
      Numenta's classic update:
  
       - Visible to hidden: $ \Delta W_{ij} = y_i \cdot  ( \varepsilon_{\small{+}} \ x_j - \varepsilon_{\small{-}} \ \bar x_j ) $
       - Bias:              $ b_{i}  = B_b \cdot \alpha_i $