Layer Input Expectation Doesn't Match (Neural Network)

14 次查看(过去 30 天)
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');

采纳的回答

Matt J
Matt J 2024-5-2
'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 个评论
Candace
Candace 2024-5-3
Thank you Matt for your help. I was able to find the error was related to the function I used to create the arrays.
Matt J
Matt J 2024-5-3
You're welcome, but if your question is resolved now, please Accept-click the asnwer.

请先登录,再进行评论。

更多回答(0 个)

类别

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

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by