I had the same problem. You need to import it.
from keras.metrics import top_k_categorical_accuracy
For top 3, create a new function with different default.
inTop3 = lambda x, y: top_k_categorical_accuracy(x, y, k=3)
model.compile(..., metrics=[inTop3])
On Saturday, November 5, 2016 at 12:26:46 PM UTC-7, Chen-Ping Yu wrote:Hi all,
From the Keras documentations, there's a metric called "top_k_categorical_accuracy", I'm having trouble knowing how to actually use that in the code, because almost everywhere is using the example of
model.compile (..., metrics=['accuracy'])
so i tried model.compile(..., metrics=['top_k_categorical_accuracy']) but it doesn't work, tried a lot of other stuff and nothing worked either.
in addition, how do I change the k from the default of 5 to, say, 3?
Thanks in advance!
--To view this discussion on the web, visit https://groups.google.com/d/msgid/keras-users/2ea488ed-5d76-4452-9c53-2eb9cf6cdba7%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users+unsubscribe@googlegroups.com.
For top-1 (which is the same as 'accuracy' metric, use: