Hi @Masaya ,
Let me address your query regarding, “I tried modifying the code to accommodate these new images, but I'm facing some issues. I would like to change the following points.The pear image uses the front, an image moved approximately 90 degrees to the left or right from the front, and a Depth image.I want to put all my data in a datastore.Currently, the code listed is the code that I have modified, but in this state an error occurs and it is impossible to predict.Please lend me your strength.”
Please see my response to your comments below.
The error messages indicate two main problems in your code.
Error#1: The output size of the last layer in your neural network does not match the response size (the expected dimensions of your labels).
Error#2: It seems that you're trying to replace a layer that does not exist in your `LayerGraph`.
To resolve the output size mismatch, you need to make sure that the last layer of your neural network corresponds correctly to the shape of your target variable (`YTrain`). Check what shape your `YTrain` has after you create it:
% make sure this is a column vector if you expect a single output per sample
YTrain = [data];
YTrain = arrayDatastore(YTrain);
If `YTrain` is a matrix of dimensions `[N x 1]`, then the last layer of your network should also have an output size of `[1]` (for regression tasks). Also, if you're using a layer like `fullyConnectedLayer`, ensure it matches:
finalLayer = fullyConnectedLayer(1, 'Name', 'finalLayerName');
Now, addressing issue about replacing layers, if you do not know what layers are present, use:
% Load or create your LayerGraph
lgraph_2 = layerGraph('your_model_name');
disp(lgraph_2.Layers); % Display all layers in the graph
If `finalLayerName` does not exist, replace it with the actual name from your `lgraph_2.Layers` list.
I did notice that your approach to combining datastores looks good, but make sure that all datastores have matching dimensions. When combining:
ds = combine(XImageTrainFront, XImageTrainSide, XDispTrain, YTrain);
Verify that each image datastore corresponds correctly to its labels.
Also, your training options seem well-defined; however, be cautious with learning rates and epochs. Sometimes starting with a higher learning rate can yield better convergence early on.
I will also make following suggestions, consider augmenting your data further to improve robustness (e.g., rotations, flips). Make sure that your validation dataset is representative of potential real-world scenarios to avoid overfitting. After predicting (`YPredicted`), consider using metrics like Mean Absolute Error (MAE) alongside RMSE for a comprehensive evaluation.
By making sure that your output layer matches the dimensions of your training labels and verifying that all layers exist as intended in your model graph, you should be able to resolve the errors you're facing. Adjusting these elements will improve your model's performance and allow for successful training with both front and side images as well as Depth data. If further issues arise, providing specific outputs or additional context will help diagnose any lingering problems effectively.