# How would you a apply a cnn to do age estimation on static images? [closed]

After doing some reading on age estimation using the IMDB wiki dataset I wanted to try it out myself on a smaller scale but I dont quite understand the application of the CNN. Any clarification would be great.

## closed as too broad by Stephen Rauch, kbrose, Aditya, OmG, Siong Thye GohDec 10 at 3:01

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

With a CNN, one of the typical (and simplest) approaches is to perform classification or regression: you train a network with a set of labeled images (supervised learning) with the aim of, after the training, the network will be able to assign the correct label (among the available labels in the training set) to a new image (never seen before).

Basically, you need:

• Decide which are your labels: they can be ages from 0 to 100, so you will have 101 labels. You can decide that you have 10 labels, 0-10, 10-20, and so on... For regression you can use real numbers within a range...
• Training labeled data: set o pairs $$(img,l)$$ where $$img$$ refers to images and $$l$$ to labels, i.e. for each image there exists only one label among those you have decided to use
• Testing labeled data: the same as above, but this images won't be used to train the network. They will be used to test its performance
• CNN: design a Convolutional Neural Network (or get one done) to perform classification or regression. There are lots of examples out there
• Train the CNN on your training data set, get the appropriate performance metric
• Test the CNN on your test set after training, with the same performance metric
• Compare training results with test results to evaluate the bias, variance and overfitting issues of the network

EDIT (following Mark.F comment):

The network will be slightly different if you try to perform classification or regression: for classification, the network can only assign one of the values (typically integers in this scenario) that are available in the training data. For regression, the network will assign a certain value within a range for each image (for example 0-100). The cost functions for both types or network are different and usually also the last layers. What you do need for both approaches is labeled data.

The CNN are used with images because they use 2D filtering over them to extract the most important features. Basically, the CNN can learn the most important "aspects" of the images that best help to perform the desired task

• In my opinion, this problem is more suited to regression. – Mark.F Dec 4 at 16:33
• For sure, it could be... I tried to point out one approach, maybe the simplest or more intuitive one. One of the problems with classification is that it will penalize the same a given age of 10 or 90 for a true age of 70. Other approaches are ordinal classification, fuzzy classifiers, etc – ignatius Dec 4 at 16:37
• Well, it's worth editing the answer to include regression, no major changes are needed for that. Thanks – ignatius Dec 4 at 16:46
• @Mark, if you don't mind me asking why would this problem be suited more for regression? – BearsBeetBattlestar Dec 5 at 4:26
• Because in a classification problem, the different classes don't have any relationship between each other (a sample is either classified correctly or wrong). So in this case, an image of a 50 year-old person will get the same treatment if its classified as a 9-year-old and as a 51-year-old. During the training the network will have to learn that 50 and 51 year-old are very close related in an unsupervised manner. That is not the case for regression, which will view the age output as a continues variable. – Mark.F Dec 5 at 12:08