Computes hamming distance.
tfa.metrics.hamming_distance(
actuals: tfa.image.color_ops.TensorLike
,
predictions: tfa.image.color_ops.TensorLike
) -> tf.Tensor
Hamming distance is for comparing two binary strings.
It is the number of bit positions in which two bits
are different.
Args |
actuals
|
actual target value
|
predictions
|
predicted value
|
Returns |
hamming distance: float
|
Usage:
actuals = tf.constant([1, 1, 0, 0, 1, 0, 1, 0, 0, 1],
dtype=tf.int32)
predictions = tf.constant([1, 0, 0, 0, 1, 0, 0, 1, 0, 1],
dtype=tf.int32)
result = hamming_distance(actuals, predictions)
print('Hamming distance: ', result.numpy())