Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A Suspected Bug in categorical_crossentropy #6805

Open
cheyennee opened this issue Dec 8, 2023 · 0 comments
Open

A Suspected Bug in categorical_crossentropy #6805

cheyennee opened this issue Dec 8, 2023 · 0 comments

Comments

@cheyennee
Copy link

I found that the the calculation result of categorical_crossentropy loss function is different from other deep learning libraries, such as tensorflow.

repo code:
theano 1.0.4

import numpy as np
from theano import tensor as T
y_true = np.array([0., 1., 0.], dtype=np.float32)
y_pred = np.array([0.9999999, 0.9999999, 0.0000001], dtype=np.float32)
res = T.nnet.categorical_crossentropy(y_pred, y_true)
print("loss = ", res.eval())
# loss =  1.192093e-07

tensorflow 2.0.0

import numpy as np
import keras
y_true = np.array([0., 1., 0.], dtype=np.float32)
y_pred = np.array([0.9999999, 0.9999999, 0.0000001], dtype=np.float32)
res = keras.losses.categorical_crossentropy(y_true, y_pred)
print("loss = ", res.numpy())
# loss =  0.69314724
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant