Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _count_oracle0 = 0
- _count_oracle1 = 0
- _count_oracle2 = 0
- def sigmoid(w):
- res = scipy.special.expit(w)
- return res
- def predict(w):
- return sigmoid(X @ w)
- def oracle0(w):
- p = X @ (w)
- res = -np.mean(y*p - np.logaddexp(0, p))
- global _count_oracle0
- _count_oracle0 += 1
- return res
- def oracle1(w):
- global _count_oracle1
- _count_oracle1 += 1
- return X.T @ (predict(w) - y) / X.shape[0]
- def oracle2(w, d):
- global _count_oracle2
- _count_oracle2 += 1
- res = X @ d
- res = (predict(w) * (1 - predict(w))) * res
- res = X.T @ res
- return res / X.shape[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement