Data Division in MATLAB Neural Network Train Command
显示 更早的评论
While training a neural network in MATLAB I am using "train" command. Is this command auto divide the data into training, testing, and validation sets or we have to divide the data manually.
回答(1 个)
Greg Heath
2016-9-13
编辑:Greg Heath
2016-9-13
Consider the example in the fitnet help documentation:
help fitnet
[x,t] = simplefit_dataset; net = fitnet(10);
net = train(net,x,t); view(net)
y = net(x); perf = perform(net,t,y)
or, better yet, the "greg" version. Notice the absent
semicolons for automatic printing to sceen
close all, clear all, clc
[x,t] = simplefit_dataset;
[ I N ] = size(x) % [ 1 94 ]
[ O N ] = size(t) % [ 1 94 ]
plot(x,t); hold on
vart1 = var(t,1) % Reference MSE = 8.3378
net = fitnet; % H = 10 default
% However, the 4 local extrema in the plot suggest
% that H = 4 is optimal
rng(0) % For replication
[net tr y e ] = train(net,x,t);
% y = net(x); e = t-y;
view(net)
plot( x ,y ,'r--' ) % Recent modification
NMSE = mse(e)/ vart1 %1.7558e-05
Rsq = 1-NMSE % 1.000
Now, to answer your question, type in the
command window
>> net.divideFcn
ans =
dividerand
>> net = net % No semicolon
ans = SURPRISE !!!
类别
在 帮助中心 和 File Exchange 中查找有关 Pattern Recognition 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!