Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @staticmethod
- def calculate_cost(y, y_hat):
- num_train_examples = y_hat.shape[1]
- cost = np.sum(- np.dot(y_hat, np.log(y).T) - np.dot(1 - y_hat, np.log(1 - y).T)) / num_train_examples
- cost = np.squeeze(cost)
- return cost
- @staticmethod
- def __sigmoid(x):
- return 1.0 / (1.0 + np.exp(-x))
- @staticmethod
- def __sigmoid_derivative(x):
- return x * (1.0 - x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement