Guest User

Untitled

a guest
Jan 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. class my_NN(object):
  2. def train(self, X, y, iteration=33):
  3. for i in range(iteration):
  4. y_hat = self._forward_propagation(X)
  5. loss = self._loss(y_hat, y)
  6. self._backward_propagation(X,y)
  7. self._update()
  8. if i%10==0:
  9. print("loss: ", loss)
  10.  
  11. def predict(self, X):
  12. y_hat = self._forward_propagation(X)
  13. y_hat = [1 if i[0]>0.5 else 0 for i in y_hat.T]
  14. return np.array(y_hat)
  15.  
  16. def score(self, predict, y):
  17. cnt = np.sum(predict==y)
  18. return (cnt/len(y))*100
Add Comment
Please, Sign In to add comment