harvitronix / five-video-classification-methods

Code that accompanies my blog post outlining five video classification methods in Keras and TensorFlow
https://medium.com/@harvitronix/five-video-classification-methods-implemented-in-keras-and-tensorflow-99cad29cc0b5
MIT License
1.18k stars 478 forks source link

why the extracted features have sequence in each of them? #33

Closed ganav closed 6 years ago

ganav commented 6 years ago

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)

harvitronix commented 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.