Layer Input Expectation Doesn't Match (Neural Network)
19 views (last 30 days)
Show older comments
Creating a dlnetwork with three inputs and two outputs. The inputs are x, y, z coordinates in the form of UTMN, UTME, and height. The outputs are pressure and temperature. Data is from multiple well logs and is organized by well ID, UTMN, UTME, height, temp, and pressure.
I seperated the data into training and validation sets. Training data: train_x_array (3 feature inputs) and train_y_array (2 feature outputs). Validation: val_x_array and val_y_array.
Keep getting errors such as:
Training stopped: Error occurred
Error using trainnet
Layer 'input': Invalid input data. Invalid size of channel dimension. Layer expects input with channel dimension size 3
but received input with size 189.
Error in final3 (line 25)
netTrained = trainnet(train_x_array_transposed, train_y_array_transposed, net,"mse", opts);
In an effort to fix the issue, I transposed the x and y arrays for both the training and validation sets. However, I am still getting the same error. I am at a loss for how to fix the error. If I try to use the Deep Network Designer, I receive an error stating their are multiple observations. The x and y values are the same for different heights/temps/pressures from the same well. I am assuming this is were the issue arises, but I do not understand why the designer would produce a different error.
Example data (before transposing):
x y z T P
4407300 327880 2796 344.3 501
4407300 327880 2746 356.5 521
4407300 327880 2696 357 541
Where train_x would be the first 3 columns, and train_y is the last 2.
Full Code:
inputSize = 3;
hiddenLayerSize = 20;
outputSize = 2;
layers = [
featureInputLayer(inputSize)
fullyConnectedLayer(hiddenLayerSize, 'Name', 'fc1')
reluLayer('Name', 'relu1')
fullyConnectedLayer(outputSize, 'Name', 'output')
];
net = dlnetwork(layers);
opts = trainingOptions('adam', ...
'MaxEpochs', 100, ...
'MiniBatchSize', 64, ...
'ValidationData', {val_x_array_transposed', val_y_array_transposed'}, ...
'ValidationFrequency', 10, ...
'Verbose', true ...
);
netTrained = trainnet(train_x_array_transposed, train_y_array_transposed, net,"mse", opts);
Y_pred_val = predict(netTrained, val_x_array');
0 Comments
Accepted Answer
Matt J
on 2 May 2024
'ValidationData', {val_x_array_transposed', val_y_array_transposed'}
From the naming you have used here, it appears that you have transposed your validation data twice (and hence untransposed them).
5 Comments
Matt J
on 3 May 2024
You're welcome, but if your question is resolved now, please Accept-click the asnwer.
More Answers (0)
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!