How to calculate accuracy, precision and recall, and F1 score for a keras sequential model?
if you want to compute this for every class then:

def recall(y_true, y_pred,class_to_analyse):
     pred = K.argmax(y_pred)
     true = K.argmax(y_true)
     p = K.cast(K.equal(pred,class_to_analyse),'int32')
     t = K.cast(K.equal(true,class_to_analyse),'int32')
     # Compute the true positive
     common = K.sum(K.dot(K.reshape(t,(1,-1)),K.reshape(p,(-1,1))))
     # divide by all positives in t
     recall = common/ (K.sum(t) + K.epsilon)
     return recall

def precision(y_true, y_pred,class_to_analyse):
     pred = K.argmax(y_pred)
     true = K.argmax(y_true)
     p = K.cast(K.equal(pred,class_to_analyse),'int32')
     t = K.cast(K.equal(true,class_to_analyse),'int32')
     # Compute the true positive
     common = K.sum(K.dot(K.reshape(t,(1,-1)),K.reshape(p,(-1,1))))
     # divide by all positives in t
     precision = common/ (K.sum(p) + K.epsilon)
     return precision

def fbeta(y_true, y_pred,class_to_analyse):
    beta = 1 # for f1 score 
    precision = precision(y_true, y_pred,class_to_analyse)
    recall = recall(y_true, y_pred,class_to_analyse)

    beta_squared = beta ** 2
    return (beta_squared + 1) * (precision * recall) / (beta_squared * precision + recall)


to make it work you need to create a list of function with a fixed class (ex: recall_1(y_true, y_pred) = recall(y_true, y_pred,class_to_analyse = 1)