How to solve this error?
古いコメントを表示
Dear matlab team,
How to solve this error?
Invalid training data. For numeric array image input, predictors must be a 4-D array of images.
for this
trainedNet = trainNetwork(gaborResponses, imdsTrain.Labels, layers, options)
please guide us
1 件のコメント
Arnav
2024 年 7 月 12 日
移動済み: Walter Roberson
2024 年 7 月 12 日
回答 (1 件)
Garmit Pant
2024 年 7 月 5 日
Hello Arnav
Given the function used and the error encountered, I gather that you are trying to train a neural network using the “trainNetwork” function and are encountering an error because of the format of the input training data.
The “trainNetwork” function expects either a datastore, a numeric array or a table as the input for the predictor. Given the error, the ‘gaborResponses’ parameter is a numeric array. For 2-D images, the function expects a ‘h-by-w-by-c-by-N’ numeric array, where h, w, and c are the height, width, and number of channels of the images, respectively, and N is the number of images.
Check the dimensionality of ‘gaborResponses’ using the following code snippet:
size(gaborResponses)
If the input images are single channel images and ‘gaborResponses’ is 3-D numeric array, reshape it using the following code snippet:
gaborResponses = reshape(gaborResponses, height, width, 1, numberOfImages);
This shall help you eliminate the error.
Additionally, the “trainNetwork” function is not recommended for use. Instead, the “trainnet” function is recommended. For further understanding, refer to the documentation of the “trainnet” function:
I hope you find the above explanation and suggestions useful!
5 件のコメント
Arnav
2024 年 7 月 8 日
移動済み: Walter Roberson
2024 年 7 月 8 日
Walter Roberson
2024 年 7 月 8 日
The return type of the image function is a handle to matlab.graphics.primitive.Image
It is recommended to avoid naming a variable image
Arnav
2024 年 7 月 11 日
Walter Roberson
2024 年 7 月 11 日
The most common cause of that message, is if gaborResponses needs to be transposed to match the length of the labels.
カテゴリ
ヘルプ センター および File Exchange で Define Shallow Neural Network Architectures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!