Implement Ridge Regression Equation for a Neural Network MATLAB
I am trying to replicate the following equation in MATLAB to find the optimal output weight matrix of a neural network from training using ridge regression.
Output Weight Matrix of a Neural Network after Training using Ridge Regression:
My attempt is below. Note that y_i is a T by 1 vector and y_i_target is also a T by 1 vector. Wout_i is a N by 1 vector where N is the number of nodes in the neural network. I generate a Wout_i,y_i,y_i_target for each i^th target training signal. I do not compute Wout_i,y_i,y_i_target in my reproducible example for sake of simplicity.
Ny = 1000; % number of training signals
T = 100; % time length of each training signal
reg = 10^-4; % ridge regression coefficient
outer_sum = 0;
for i = 1:Ny
Wouts{i} = Wout_i; % collected cell matrix of each Wout_i for each i^th target training signal
inner_sum = sum(((y_i-y_i_target).^2)+reg*norm(Wout_i)^2);
outer_sum(i) = inner_sum;
end
outer_sum = outer_sum.*(1/Ny);
[minval, minidx] = min(outer_sum);
Wout = cell2mat(Wouts(minidx));
My final answer for Wout is a N by 1 as it should be, but I am uncertain in my answer. I am particularly unsure whether or not I have done the double summation and arg min with respect to Wout operations correctly. Is there any way to validate my answer?I am trying to replicate the following equation in MATLAB to find the optimal output weight matrix of a neural network from training using ridge regression.
Output Weight Matrix of a Neural Network after Training using Ridge Regression:
My attempt is below. Note that y_i is a T by 1 vector and y_i_target is also a T by 1 vector. Wout_i is a N by 1 vector where N is the number of nodes in the neural network. I generate a Wout_i,y_i,y_i_target for each i^th target training signal. I do not compute Wout_i,y_i,y_i_target in my reproducible example for sake of simplicity.
Ny = 1000; % number of training signals
T = 100; % time length of each training signal
reg = 10^-4; % ridge regression coefficient
outer_sum = 0;
for i = 1:Ny
Wouts{i} = Wout_i; % collected cell matrix of each Wout_i for each i^th target training signal
inner_sum = sum(((y_i-y_i_target).^2)+reg*norm(Wout_i)^2);
outer_sum(i) = inner_sum;
end
outer_sum = outer_sum.*(1/Ny);
[minval, minidx] = min(outer_sum);
Wout = cell2mat(Wouts(minidx));
My final answer for Wout is a N by 1 as it should be, but I am uncertain in my answer. I am particularly unsure whether or not I have done the double summation and arg min with respect to Wout operations correctly. Is there any way to validate my answer? I am trying to replicate the following equation in MATLAB to find the optimal output weight matrix of a neural network from training using ridge regression.
Output Weight Matrix of a Neural Network after Training using Ridge Regression:
My attempt is below. Note that y_i is a T by 1 vector and y_i_target is also a T by 1 vector. Wout_i is a N by 1 vector where N is the number of nodes in the neural network. I generate a Wout_i,y_i,y_i_target for each i^th target training signal. I do not compute Wout_i,y_i,y_i_target in my reproducible example for sake of simplicity.
Ny = 1000; % number of training signals
T = 100; % time length of each training signal
reg = 10^-4; % ridge regression coefficient
outer_sum = 0;
for i = 1:Ny
Wouts{i} = Wout_i; % collected cell matrix of each Wout_i for each i^th target training signal
inner_sum = sum(((y_i-y_i_target).^2)+reg*norm(Wout_i)^2);
outer_sum(i) = inner_sum;
end
outer_sum = outer_sum.*(1/Ny);
[minval, minidx] = min(outer_sum);
Wout = cell2mat(Wouts(minidx));
My final answer for Wout is a N by 1 as it should be, but I am uncertain in my answer. I am particularly unsure whether or not I have done the double summation and arg min with respect to Wout operations correctly. Is there any way to validate my answer? neural network, machine learning, matlab, for loop, sum, code generation, regression MATLAB Answers — New Questions