Error While Training Network With Regression Layer

2 次查看(过去 30 天)
Hello,
I am trying to design a deep netwrok using 'Deep Network Designer' App. When I am trying image classification it works good but when I built a network for image regression I got an error as shown when I TRAIN the netwrok, but didn't get any while ANALYZing
I checked my design and steps with instructions given within this link Image-to-Image Regression in Deep Network Designer - MATLAB & Simulink (mathworks.com), but still getting this error frequently in TRAINing phase. Thank you in advance.

回答(1 个)

Aniket
Aniket 2024-10-11
Hi @BR,
The error you are encountering is due to invalid training data for regression tasks. This can occur if the responses are not in the correct format (vector, matrix, or 4-D array of numeric responses) or if there are NaNs present in the data. NaNs can exist in the original dataset or may have been introduced by preprocessing functions used for generating training data.
You can follow the below steps to resolve the issue:
1. Make sure the original dataset does not have any NaNs present. You can do so by running these lines of code:
% Check if any of the data contains NaNs
data = dsTrain.read();
inputs = data.InputImage;
outputs = data.ResponseImage;
anyNaNsInInput = any(cellfun(@(x)any(isnan(x),"all"),inputs,'UniformOutput',true))
anyNaNsInOutput = any(cellfun(@(x)any(isnan(x),"all"),outputs,'UniformOutput',true))
2. Ensure that your response data is in the required format. If the response data is not numeric, convert it to a numeric type. This is necessary because regression models require numeric inputs to perform calculations. Also verify that the dimensions of your input and output data are consistent and compatible with each other. Reshape the data if necessary to meet the model's requirements.
3. If you are using Data Augmentation techniques, NaNs can be avoided by removing random rotation and only using reflection data augmentation.
augmenter = imageDataAugmenter( ...
'RandXReflection',true);
4. I was not able to reproduce this error in MATLAB R2024b. Hence upgrading to latest version should resolve this issue.
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by