Extracting a number from keras compile function

I am unsure if the title is even the problem I am having. It is more of just having an issue understanding what I need to do

I am training a dataset with age in humans and when I run model’s compile metrics=‘accuracy’, I don’t want it to compute the exact accuracy, but just look for a certain age range and compute the accuracy if it correctly identifies the age range. I am wondering how I could do this. Can I simply edit the compile function?

So what I am starting with is <https://github.com/yu4u/age-gender-estimation>

What I am trying to do is to extract the age, check if it is in a certain range, say 20 - 30 and then determine the accuracy based on if the program is correct in seeing it is 20 - 30 as opposed to checking the accuracy if the program can recognize the exact age. What I thought would be easiest is to add a new metric to the model.compile function seen in lines 71-72 of the train.py file

model.compile(optimizer=sgd, loss=[“categorical_crossentropy”, “categorical_crossentropy”],
metrics=[‘accuracy’])

A problem I am having is I am not sure how to check the actual age from this file to plug it into the custom metric or even creating a callback

From here, I assume I would have to edit the plot_history.py file to actually plot the accuracy.

If anybody has any ideas, that would be a tremendous help

Thank you

Thank you I asked the same thing on stackoverflow but no one has replied and I am in desperate need of helphttps://stackoverflow.com/questions/49396284/extracting-a-number-from-keras-compile-function