Also, if you need more details on how the data is exactly being collected, this previous thread showed how exactly the data itself was collected. (Ignore the way that I structured the training data in that previous example as I figured out that it was wrong)
How should I structure the neural net based on my given input and output training data
2 次查看(过去 30 天)
显示 更早的评论
I am trying to design a feedforward network that trains on a 4x5 matrix (5 samples of 4 separate inputs into the neural network) and its outputs are represented by a 4x5x1000 matrix (5 samples of 4 outputs where each component of the 4x1 output vector has 1000 points). This neural net is used to determine an optimal trajectory for a given terminal condition from a set of the same initial conditions . The code for this project will be placed below:
%% Neural Net Training Process
% Initial State
x1 = [0;0]; % Initial Positions
x2 = [1;1]; % Initial Velocities
xo = [x1;x2]; % 4x1 Initial State Vector
% Parsing Training Input Data
x_input = [xf1,xf2,xf4,xf5,xf6]; % 4x5 Terminal State Vector (each xf (4x1) represents a different terminal condition)
% Parsing Training Output Data
x_output = [];
for i=1:4
x_output(i,1,:) = x1(:,i);
x_output(i,2,:) = x2(:,i);
x_output(i,3,:) = x4(:,i);
x_output(i,4,:) = x5(:,i);
x_output(i,5,:) = x6(:,i);
end % 4x5x1000 Terminal State Matrix
% Parsing Validation Data
xf_valid = xf3;
x_valid = x3';
% Neural Net Architecture Initialization
netconfig = 40;
net = feedforwardnet(netconfig);
net.numInputs = 4;
% Training the Network
for j=1:5
curr_xin = x_input(:,j);
curr_xout = x_output(:,j,:);
net = train(net,curr_xin,curr_xout);
end
From here, I am receieve an error in line 89, where I get the following error: Error using nntraining.setup>setupPerWorker (line 96)
Targets T is not two-dimensional. Any advice from here would be appreciated. Thanks.
回答(1 个)
Himanshu
2024-8-8
Hi,
I see that you are facing an error related to the dimensionality of the targets in your neural network training process. This issue can be solved by ensuring that your target data "x_output" is properly formatted to match the expected dimensions of the neural network.
To solve this issue, you need to reshape your target data so that it matches with the two-dimensional requirement of the neural network's training function.
Ensure that "x_output" is reshaped into a 2D matrix where each column represents a target vector. Also, modify the training loop to handle the reshaped target data correctly.
Please refer to the below documentations for more information.
- Generate feedforward neural network: https://www.mathworks.com/help/deeplearning/ref/feedforwardnet.html
- Manage and preprocess data for deep learning: https://www.mathworks.com/help/deeplearning/process-data-for-deep-neural-networks.html
- Reshape array by rearranging existing elements: https://www.mathworks.com/help/matlab/ref/reshape.html
I hope this helps.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!