Control the epochs while training a neural network
12 次查看(过去 30 天)
显示 更早的评论
I am trying to train a BP neural network with the following codes. I mean to run the iterations for 1000 epochs. However, when the net.trainParam.goal = 0 is achieved, the training process will stop, which is much less than 1000.
How can I set some parameters so that I can train the neural network for 1000 times. I can to plot MSE VS. epoch.
Thanks!
%%%%%%%%%%%%%%%%%%%% clear all; close all; clc;
% Number of Inputs(n), Outputs(r) and neurons in hidden layer(m) n = 1; r = 1; m = 12; % Number of training values (epochs) epochs = 1000; % Input value range x_min = -1; x_max = 1; for k = 1:n x_train(k,:) = x_min + (x_max-x_min)* rand(epochs,1); end % Desired values for random vector x_train y_des = 2*x_train.^2 + 1;
net = feedforwardnet(m);
net.trainParam.epochs = 1000; % epoch net.trainParam.show = 10; % show frequency net.trainParam.goal = 0; % objective MSE
net = train(net, x_train, y_des);
0 个评论
采纳的回答
Greg Heath
2012-9-5
The purpose of training is to reduce mse to a reasonably low value in as few epochs as possible. When training is sufficiently long, the plot of mse will asymptotically decrease to a horizontal straight line at mse = 0.
Therefore, your request makes no sense to me.
In fact, if the training target is standardized (zero-mean/unit-variance rows) via the functions zscore or mapstd, there is no practical reason to reduce mse below
~mean(var(transpose(target)))/100.
Hope this helps.
Greg
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sequence and Numeric Feature Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!