4

1

I have a code that computes the accuracy, but now I would like to compute the F1 score.

```
accuracy_1 = tf.reduce_mean(tf.cast(tf.equal(
tf.argmax(output_1, axis=-1),
tf.argmax(y_1, axis=-1)), tf.float32), name="accuracy_1")
accuracy_2 = tf.reduce_mean(tf.cast(tf.equal(
tf.argmax(output_2, axis=-1),
tf.argmax(y_2, axis=-1)), tf.float32), name="accuracy_2")
```

How can I compute F1 equivalent for the above code? I'm finding it difficult as I am very new to TensorFlow.

2Hi, thanks a lot for the reply. I know how to compute f1, but i want it in tensorflow, i basically want to replace the above code mentioned with f1. – William Scott – 2019-03-30T09:01:16.147

1

tensorflow has a tf.metrics function, see here https://www.tensorflow.org/api_docs/python/tf/metrics

– Hunar – 2019-03-30T09:09:01.6632i saw that, but it doesnt' seem to work. That's the reason i posted here. – William Scott – 2019-03-30T10:18:16.157