I want to write a custom metric in Keras (python) to evaluate the performance of my sequence to sequence model as I train. Sequences are one-hot encoded and the tokens are words instead of characters. I want it to report the number of sequences that are FULLY correct only (percentage would be okay too). So if it predicts "The cat sits on the mat" instead of "the cat sat on the mat" that would be incorrect and would not be counted.
Keras has (in my opinion) limited documentation on writing custom metrics (here https://keras.io/metrics/). Basically, what I want is something like
import keras.backend as K
def num_correct(y_true, y_pred):
return K.sum(float(y_pred == y_true))
Now, Keras doesn't like this. It says that float has no attribute shape. I know that y_true and y_pred are tensors, but I'm not fully sure what it wants returned. Help is appreciated.