title: In linear regression, i am getting NAN values for cost and weights
body: <pre><code>    import numpy as np
      def cost_function(X,Y,B):
         J = np.sum((X.T.dot(B)-Y) ** 2) / (2 * len(Y))
         return J
      def gradient_descent(X,Y,B,alpha,iterations): 
          cost_history = [0] * iterations    
          for iteration in range(iterations):  
              h = X.T.dot(B)
              loss = h - Y
              gradient = X.dot(loss) / len(Y)
              B = B + (alpha * gradient)
              cost = cost_function(X,Y,B)
              cost_history[iteration] = cost
          return B,cost_history
  </code></pre>
  
  <p>B--weights (2,1)
  X--input(2,700)
  Y--output(700,1)
  alpha--learning rate (0.001)
  iterations -- 3000
  i am using cost function to calculate the error</p>