How to run the code by moving one column to next and repeat the algorithm
3 次查看(过去 30 天)
显示 更早的评论
I have a code of neuaral network, where my number of input is 3 (matrix dimension is 20 by 3) and target is 20 by 900. I want to run the code with three inputs and 1st column of target and store the predicted output in a matrix A, similar dimension (20 by 900). Then move to 2nd coloumn of target with same input and run the code and store it in A and so on upto 900 array.
I am not understanding how to do it. Please provide me your suggestion to solve it.
Thank you.
0 个评论
回答(1 个)
Satwik
2025-3-17
I understand that you have a neural network with inputs of size 20x3 and a target matrix of size 20x900. You want to predict each column of the target individually using the same inputs and store the results in a matrix A of the same size (20x900).
To achieve this in you can loop through each column of the target matrix, perform predictions using your neural network, and store the results in 'matrix A'. Here is an example implementation for the approach:
% Assuming 'net' is your trained neural network
% 'inputs' is your input matrix (20x3)
% 'target' is your target matrix (20x900)
% Initialize matrix A
A = zeros(size(target));
% Iterate over each column of the target
for i = 1:size(target, 2)
% Extract the current column of the target
current_target = target(:, i);
% Run the neural network with the inputs
% Note: Ensure your neural network function is set up to handle
% input and output dimensions correctly.
predicted_output = net(inputs')'; % Transpose if net requires column vectors
% Store the predicted output in the corresponding column of A
A(:, i) = predicted_output;
end
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!