How to run the code by moving one column to next and repeat the algorithm

5 vues (au cours des 30 derniers jours)
AS
AS le 6 Avr 2022
Réponse apportée : Satwik le 17 Mar 2025
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.

Réponses (1)

Satwik
Satwik le 17 Mar 2025
Hi @AS,
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!

Catégories

En savoir plus sur Sequence and Numeric Feature Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by