Training Neural Network for Image-to-Image-Regression using Numeric Array
12 次查看(过去 30 天)
显示 更早的评论
Hi,
I would like to train the Neural Network I created for Image-to-Image-Regression using a Numeric Arrays. I already did it using a combined Imagedatastore, containing the input-data (60x60x1 images) and the expected output-data (60x60x1 images). Now I tried to do the same but with two numeric arrays, one for the input-data (60x60x1xn, n: number of images) and one for the output data (60x60x1xn). First I tried to use the two numeric arrays like this: trainNetwork(input,output,mynetwork,options). The training worked but the results where very different, the netork always predicted the input picture.
Then I created two Array-Datastores, one for the input and one for the outout and combined the two Array-Datastores, like I did it before with the ImageDatastores. I then tried to train my network like this: trainNetwork(combinedDatastore,mynetwork,options) and got this error message: "Invalid training data. For a network with 1 inputs and 1 output, the datastore read function must return a cell array with 2 columns, but it returns a cell array with 1 columns."
I would be really thankful, if someone could help me. Thanks!
2 个评论
Rahul Gulia
2024-4-8
Could you please direct me to some tips on how did you modify the training and testing data with image as an input and an image as the output. And how did you modify the train model to predict the images from the input dataset (also images).
I am trying to solve a similar kind of problem. I would really appreciate any kind of suggestion on this topic.
Thank you,
Rahul
采纳的回答
Sandeep
2023-4-25
Hi Benedikt Hamann,
The trainNetwork function expects the training data to be returned from the datastore's read function in a specific format. For a network with one input and one output, the read function must return a cell array with two columns, where each row contains an input and its corresponding output.
When you tried to train the network using the two numeric arrays, you passed the inputs and outputs as separate arguments to the trainNetwork function. This works for simple cases, but may not be the best approach when dealing with more complex data or when using datastores.
When you created the Array-Datastores for the input and output data, you need to make sure that the read function returns data in the correct format.
Here is an example of a read function definition,
inputDs = arrayDatastore(inputData, 'IterationDimension', 4, 'ReadFcn', @(x) {x, []});
This ReadFcn will return a cell array with two columns, where the first column contains the input data and the second column contains an empty array (since this is the input datastore and there is no corresponding output data).
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!