Advertisement
Guest User

Untitled

a guest
May 26th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. @staticmethod
  2. def calculate_cost(y, y_hat):
  3. num_train_examples = y_hat.shape[1]
  4. cost = np.sum(- np.dot(y_hat, np.log(y).T) - np.dot(1 - y_hat, np.log(1 - y).T)) / num_train_examples
  5. cost = np.squeeze(cost)
  6.  
  7. return cost
  8.  
  9. @staticmethod
  10. def __sigmoid(x):
  11. return 1.0 / (1.0 + np.exp(-x))
  12.  
  13. @staticmethod
  14. def __sigmoid_derivative(x):
  15. return x * (1.0 - x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement