Questions about the regularization (Modified Performance Function) of neural network
5 ビュー (過去 30 日間)
古いコメントを表示
Hello, everyone. I tried to find out the best regularization ratio for a very simple problem from Matlab, using the function trainbgf for a shallow neural network. Then I plotted a validation curve. The problem is that the curve didn't make any sense. I just followed the contents from the official document as follows:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/194146/image.png)
Here are my codes.
*******************************************
regularization_term = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
m = size(regularization_term,2);
[x,t] = simplefit_dataset;
x_train = x(1:70);
t_train = t(1:70);
x_test = x(71:94);
t_test = t(71:94);
trainPerformance = zeros(50,11);
testPerformance = zeros(50,11);
for j = 1:50
for i = 1:m
net = feedforwardnet(10,'trainbfg');
net.divideFcn = '';
net.trainParam.epochs = 300;
net.trainParam.goal = 1e-5;
net.performParam.regularization = regularization_term(i);
net = train(net,x_train,t_train);
y_train = net(x_train);
trainPerformance(j,i) = sqrt(perform(net,t_train,y_train));
y_test = net(x_test);
testPerformance(j,i) = sqrt(perform(net,t_test,y_test));
end
end
plot(regularization_term, mean(trainPerformance),regularization_term,mean(testPerformance))
legend('trainperformance-RMSE','testperformacne-RMSE','best')
xlabel('Regularization Ratio')
ylabel('RMSE')
************************************************
Here is the learning curve I plotted.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/194147/image.jpeg)
I think that the RMSE of the training data should increase as the regularization ratio increases and the RMSE of the test data should decrease at first and at a certain point start to increase as the regularization ratio increases. I'm not sure where I made a mistake, can anyone give me advice? Thank you in advance!
2 件のコメント
採用された回答
Greg Heath
2018 年 8 月 24 日
Oh! … O.K.
The simplefit_dataset is smooth with 4 interior local extrema. Therefore, you probably only need H = 4 hidden nodes.
More than H = 4 hidden nodes can be considered overfitting. So, if you use the default H = 10, you will have an overfit net and should implement a mitigation to
PREVENT OVERTRAINING AN OVERFIT NET.
The most common mitigations are
1. DO NOT OVERFIT
A. No. of unknown weights <= No. of training equations:
Nw <= Ntrneq
AND/OR
B. Minimize weighted sum of SQUARED ERRORS AND SQUARED WEIGHTS
MSE + gamma * MSW
2. DO NOT OVERTRAIN:
Use a validation subset to implement EARLY STOPPING
Hope this helps.
Greg
7 件のコメント
Greg Heath
2018 年 8 月 27 日
I understood perfectly what you were doing.
My concern was/is for the less experienced readers.
Greg
その他の回答 (1 件)
Greg Heath
2018 年 8 月 24 日
% When I search the command line window for info on "regularization" :
>> help regularization
regularization not found.
Use the Help browser search field to search the documentation, or type "help help" for help command options, such as help for methods.
>> doc regularization
% No answer!
>> lookfor regularization
plotbr - Plot network performance for Bayesian regularization training.
trainbr - Bayesian Regularization backpropagation.
msereg - Mean squared error with regularization performance function.
msnereg - Mean squared normalized error with regularization performance function.
lasso - Perform lasso regularization for linear regression on tall arrays.
lassoglm - Perform lasso or elastic net regularization for a generalized linear model.
lasso - Perform lasso or elastic net regularization for linear regression.
% Therefore, it seems that for general
%(i.e., nonlinear) applications
%
% USE TRAINBR WITH MSEREG
%
% I will let you do the rest. First see the results of the following commands
>> help trainbr
>> doc trainbr
Hope this helps.
THANK YOU FOR FORMALLY ACCEPTING MY ANSWER
Greg
参考
カテゴリ
Help Center および File Exchange で Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!