MATLAB Answers

Deep Learning: How do I add regression ground truth data to an imageDatastore?

47 views (last 30 days)
Tomas on 13 Dec 2017
Commented: Simone Scaringi on 21 Feb 2020 at 19:43
if I train my network with newnet=trainNetwork(imageDatastore_traindata,net,options) imageDatastore_traindata.Labels need to be categorical, i.e. not regression but classification labels. So for regression, it seems I need to use newnet=trainNetwork(X,Y,net,options)
and give my regression labels as Y, but then I can't use the imageDatastore as X, so I'll run into memory problems. Is there no way to do regression with an imageDatastore?

  1 Comment

Bashar Saad
Bashar Saad on 28 Dec 2018
hi friend i have same the problem i do not know how to load my own dataset in deep learning could you help me plase ?

Sign in to comment.

Answers (1)

Amy MacDonough
Amy MacDonough on 19 Dec 2017
You can use an image datastore to get the image file names (without having to load the images from the dataset into memory at all), then create a table with the file names in the first column and your regressors in the other columns, and feed that into trainNetwork.
(see the trainedNet = trainNetwork(tbl,layers,options) syntax for trainNetwork.)


Show 2 older comments
Simone Scaringi
Simone Scaringi on 20 Feb 2020 at 21:33
Also joining Christoph Block with same question: i.e. is there a way to parse the tbl argument and allow the trainNetwork function to read files using e.g. a custom ReadFcn ?
Simone Scaringi
Simone Scaringi on 21 Feb 2020 at 19:43
I've spent way too much time getting my head around this.
What I ended up doing to "fix" it, is to save my data files as .png images. In my case these are just 1D "images", but I guess you can save the 3D matrix as an image as well. If you do this then train proceeds as expected since the table with file paths have .png "images" in them.
Hope this helps to whoever reads this!

Sign in to comment.

Sign in to answer this question.