We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
No description provided.
The text was updated successfully, but these errors were encountered:
class CrossEntropy(Loss): def init(self): pass
def loss(self, y, p): # Avoid division by zero p = np.clip(p, 1e-15, 1 - 1e-15) return - y * np.log(p) - (1 - y) * np.log(1 - p) def acc(self, y, p): return accuracy_score(np.argmax(y, axis=1), np.argmax(p, axis=1)) def gradient(self, y, p): # Avoid division by zero p = np.clip(p, 1e-15, 1 - 1e-15) return - (y / p) + (1 - y) / (1 - p)
loss = CrossEntropy() y = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) p = np.random.uniform(0,1,size=10) loss.loss(y, p)
Sorry, something went wrong.
def acc(self, y, p): return accuracy_score(y, p) is this ok?
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: