Regression with images

Hello,
I did age and gender classification, but now i want to modify it to try regression for age.
I have images and image name carry info about age of person.

ImageRegressionLabelGenerator labelMaker = new ImageRegressionLabelGenerator();

ImageRecordReader recordReader = new ImageRecordReader(height, width, channels, labelMaker);
recordReader.initialize(trainingData, getImageTransform());
DataSetIterator dataSetIterator = new RecordReaderDataSetIterator(recordReader, batchSize, 1, 1, true);
dataNormalization.fit(dataSetIterator);
dataSetIterator.setPreProcessor(dataNormalization);
computationGraph.fit(dataSetIterator, numEpochs);

But when I start training, error is:
Labels and preOutput must have equal shapes: got shapes [32, 65] vs [32, 1]

Batch size is 32, i have 90k images in range from 0 to 64.
Last layer:
.addLayer(“outputAge”, new OutputLayer.Builder(LossFunctions.LossFunction.MSE)
.nOut(1)
.activation(Activation.IDENTITY)
.build(), “dense”);
For architecture I am using denseNet example.

How to create this, so i can make model which for provided image return age?

Take a look at our regression example here: deeplearning4j-examples/CSVDataModel.java at 9e971fdb782249873786a960f248247dd28650fa · eclipse/deeplearning4j-examples · GitHub

The key is setting up the recordreaderdatasetiterator to expect regression.

Hello,
thank for response, but i need help with preparing dataset. I see in this example that we have as input same type of data as output (string value). But how to make this if i work with images? I should provide images as input and expect numeric value (example : image of person → 47 years). Any tips how to do it?

Thanks on your time!

Check out this youtube video. Computer Generates Human Faces - YouTube
I have not done what you are doing but to play around a bit you could crop the faces with opencv and put them into an autoencoder to see what features get picked up.

After that put a feed forward network on the end of the auto encoders encoding side and do normal regression training. If you have a large dataset I think it would work.

Have you tried something like that?