Professional Documents
Culture Documents
Báo cáo tìm hiểu NN (2024-03-01)
Báo cáo tìm hiểu NN (2024-03-01)
Với y2/y1:
I.1. 1 lớp ẩn:
I.1.1. Dùng tool trong Matlab:
nftool hoặc nnstart
Nhưng mà chỉ có mạng 1 lớp ẩn, ko thể thêm số lớp ẩn được. Vậy nên dùng code để tùy chỉnh
nhiều hơn.
I.1.2. Code:
input =xlsread('D:\C. Study\6.NCKH\AI\Data AI','Data','1:4'); % tùy đường dẫn
y2y1sm =xlsread('D:\C. Study\6.NCKH\AI\Data AI','Data','5:5');
Ljy1sm =xlsread('D:\C. Study\6.NCKH\AI\Data AI','Data','6:6');
x = input;
t = y2y1sm;
% Choose a Training Function
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayerSize = 1;
netA = fitnet(hiddenLayerSize,trainFcn);
% Setup Division of Data for Training, Validation, Testing
netA.divideParam.trainRatio = 70/100;
netA.divideParam.valRatio = 15/100;
netA.divideParam.testRatio = 15/100;
% Train the Network
[netB,tr] = train(netA,x,t);
% Test the Network
y = netB(x); %Outputs of the neural network
e = gsubtract(t,y); %Generalized subtraction
performance = perform(netA,t,y); %Calculate network performance
% View the Network
view(netB);
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotregression(t,y)
%figure, plotfit(net,x,t)
I.1.3. Diễn giải:
Hàm kích hoạt trong lớp ẩn: hàm sigmoid lưỡng cực
Hàm kích hoạt trong lớp ouput: hàm tuyến tính
146 bộ số liệu dùng làm Training data (75% trên tổng 210 bộ) (gồm 4 input và 1 output)
32 bộ số liệu dùng làm Validation data (gồm 4 input và 1 output dùng để kiểm trong trong
quá trình training)
32 bộ số liệu dùng làm Test data (gồm 4 input dùng để kiểm trong trong quá trình training)
Các trọng số và bias được máy khởi tạo ngẫu nhiên và tự động.
Thuật toán sử dụng: Levenberg-Marquardt (thường nhanh nhất khi so với Bayesian
regularization hay Scaled Conjugate Gradient)
Quá trình training sẽ dừng lại khi 1 trong 6 thông số bên dưới gặp target value.
- Epoch: lần lặp thứ mấy
- Performance: Sai số bình phương trung bình (mean squared error hay MSE hay loss
function)
- Gradient: độ dốc, độ dốc nhỏ là đang tiến đến local minima
- Mu: (chưa rõ)
- Validation checks: (chưa rõ)
x = input;
t = Ljy1sm;
% Choose a Training Function
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayerSize = 1;
netA = fitnet(hiddenLayerSize,trainFcn);
% Setup Division of Data for Training, Validation, Testing
netA.divideParam.trainRatio = 70/100;
netA.divideParam.valRatio = 15/100;
netA.divideParam.testRatio = 15/100;
% Train the Network
[netB,tr] = train(netA,x,t);
% Test the Network
y = netB(x); %Outputs of the neural network
e = gsubtract(t,y); %Generalized subtraction
performance = perform(netA,t,y) %Calculate network performance
% View the Network
view(netB);
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotregression(t,y)
%figure, plotfit(net,x,t)
(Code y hệt y2/y1 1 lớp ẩn, chỉ khác dòng màu đỏ)
II.1.2. Kết quả:
x = input;
t = Ljy1sm;
% Choose a Training Function
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayerSize = [1 1];
netA = fitnet(hiddenLayerSize,trainFcn);
% Setup Division of Data for Training, Validation, Testing
netA.divideParam.trainRatio = 70/100;
netA.divideParam.valRatio = 15/100;
netA.divideParam.testRatio = 15/100;
% Train the Network
[netB,tr] = train(netA,x,t);
% Test the Network
y = netB(x); %Outputs of the neural network
e = gsubtract(t,y); %Generalized subtraction
performance = perform(netA,t,y) %Calculate network performance
% View the Network
view(netB);
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotregression(t,y)
%figure, plotfit(net,x,t)
(Code y hệt Lj/y1 2 lớp ẩn, chỉ khác dòng màu đỏ)
II.2.1. Kết quả:
2 lớp ẩn, số nơ ron lần lượt là: 1 và 1, kết quả tạm được
2 lớp ẩn, số nơ ron lần lượt là: 1 và 1, trong 1 lần training nào đó thì kết quả khá tệ