8000 A Suspected Bug in `categorical_crossentropy` · Issue #6805 · Theano/Theano · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
A Suspected Bug in categorical_crossentropy #6805
Open
@cheyennee

Description

@cheyennee

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0