addons icon indicating copy to clipboard operation
addons copied to clipboard

MatthewsCorrelationCoefficient is always zero in binary classification

Open digital-thinking opened this issue 2 years ago • 0 comments

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 11
  • TensorFlow version and how it was installed (source or binary): 2.10.1 (binary)
  • TensorFlow-Addons version and how it was installed (source or binary): 2.10.1 (binary)
  • Python version: 3.10
  • Is GPU used? (yes/no): yes

MCC does not work on binary labels with a single neuron as output, it always returns 0: Last layer:

x = tf.keras.layers.Dense(1, activation='sigmoid')(x)
model.compile('sgd', 'binary_crossentropy', metrics=['accuracy', tfa.metrics.MatthewsCorrelationCoefficient(num_classes=2)])

Output always 0: 38s 19s/step - loss: 0.6899 - accuracy: 0.4843 - MatthewsCorrelationCoefficient: 0.0000e+00 - val_loss: 0.6934 - val_accuracy: 0.4096 - val_MatthewsCorrelationCoefficient: 0.0000e+00

The last comment from the user here also describes the problem, however the solution does not work anymore https://github.com/tensorflow/addons/issues/2339

digital-thinking avatar Nov 17 '22 16:11 digital-thinking