I am having significant trouble in navigating the tensorflow syntax and functions and am struggling with the fact that Keras isn't providing me with nice np arrays.
I have a network with a single tanh activation output.
Essentially this is what I want:
y_true = [-0.4, -0.2, 0, -0.3, 0.4, 0.1, -1, 1, 0, -0.2]
y_pred = [-0.4, 0.2, 0, -0.3, -0.4, 0.1, -1, -1, 0, 1]
I want to calculate the proportion of predictions that have the same sign as the ground truth values. e.g. in the above example, this would be 7/10 or 70%
I would calculate this using perhaps:
correct = np.where((y_true * y_pred) >= 0, 1 , 0)
correct.mean()
Given the following function header for a custom metric in Keras, how would I go about doing this?
def binary_class_acc_metric(y_true, y_pred):
Many thanks