Closed ganav closed 6 years ago
@ganav You'll need to define your own accuracy metric. You can do this by passing a custom function to the metrics list in the model.compile()
call.
For example, where I have model.compile(..., metrics=['accuracy', 'top_k_categorical_accuracy'])
, you can change that to:
model.compile(..., metrics=['accuracy', top_2_categorical_accuracy, top_3_categorical_accuracy])
And then define your custom functions:
def top_2_categorical_accuracy(y_true, y_pred):
return top_k_categorical_accuracy(y_true, y_pred, k=2)
def top_3_categorical_accuracy(y_true, y_pred):
return top_k_categorical_accuracy(y_true, y_pred, k=3)
^ untested code but I think that should work.
Hello Mr
I am thankful to your code i am learning many from it. I have a question as follows: the code gives top-k score. if i define k=5 then i get only top-5 score how to get [top-1,top-2,top-3,...top-n] scores at the same time (in another word i want to plot rank)