Need Help Implementing Neural Network in MATLAB

2 次查看(过去 30 天)
Hello MATLAB community,
I am currently working on the implementation of the research paper titled "Neural Network Self-Tuning Control for a Piezoelectric Actuator" by Wenjun Li (DOI: 10.3390/s20123342).
%Equations for Weight Updates:
dW_k = eta_w * e .* Nf(y, V_k) .* Ng(y, W_k) .* (1 - Ng(y, W_k)) .* y;
dV_k = eta_v * e .* Ng(y, W_k) .* (1 - Ng(y, W_k)) .* (1 - Nf(y, V_k)) .* y;
W_k = W_k + dW_k;
V_k = V_k + dV_k;
I have provided MATLAB code snippets for weight updates in a neural network based on the equations. I'm seeking assistance in ensuring the Equations for Weight Updates are correct and also guidance on how to implement the neural network strategy described in the paper.
If anyone has experience with similar projects or is well-versed in neural networks and control systems, I would greatly appreciate your insights and advice.
Thank you in advance for your time and assistance.
  3 个评论
Achraf
Achraf 2023-10-14
Thank you for your response, I'm having trouble deriving the code from the equations we discussed. Your assistance in this matter would be greatly appreciated.
That's all I could achieve so far. I've had many iterations coding equation Nr17, but I didn't succeed!
num_iterations = 100; % the number of training iterations
eta_w = 0.01; % Learning rate for weights in Ng
eta_v = 0.01; % Learning rate for weights in Nf
function [W_k, V_k] = neural_network_self_tuning_control(num_iterations, eta_w, eta_v)
% Define activation functions
f_Ng = @(x) (1 - exp(-x)) / (1 + exp(-x)); % Sigmoid function
f_Nf = @(x) (exp(x) - exp(-x)) / (exp(x) + exp(-x)); % Hyperbolic tangent
% Initialize weights W_k and V_k
W_k = rand(1, 6); % Initialize with random values
V_k = rand(1, 6); % Initialize with random values
% Define initial input and target values
y_k = 5;
yd_k = 10;
% Training loop
for k = 1:num_iterations
% Calculate Ng[y(k); W(k)] and Nf[y(k); V(k)]
Ng_yk_Wk = f_Ng(W_k * y_k);
Nf_yk_Vk = f_Nf(V_k * y_k);
% Calculate control input u(k)
u_k = (yd_k - Ng_yk_Wk) / Nf_yk_Vk; %is derived from Equation (5) in the paper
% Update weights for Ng
delta_w = (eta_w * f_yk / Nf_yk_Vk) * %...This must be equation 17
W_k = W_k + delta_w;
% Update weights for Nf
delta_v = (eta_v * f_yk / Ng_yk_Wk) * %...This must be similar
V_k = V_k + delta_v;
end
end
Sam Chak
Sam Chak 2023-10-15
@Achraf, can you edit the code in your comment to list the equation numbers, like "% Refer to Eq. (Num)"? This can make the process of cross-checking the equations in the code easier and faster. Most volunteers on Sunday do not have the time to read the entire paper and find a match for each equation in the code.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by