【问题标题】:Data Division in MATLAB Neural Network Train CommandMATLAB 神经网络训练命令中的数据划分
【发布时间】:2017-01-20 15:49:00
【问题描述】:

在 MATLAB 中训练神经网络时,我正在使用“train”命令。该命令是自动将数据划分为训练集、测试集和验证集,还是我们必须手动划分数据。

【问题讨论】:

    标签: matlab neural-network artificial-intelligence training-data nntool


    【解决方案1】:

    是的,确实如此。但如果我们愿意,我们可以手动划分数据。应使用网络对象的net.divideFcnnet.divideParam 字段:

    t=0:0.05:8; x= sin(t);
    net = feedforwardnet(3);
    net.divideFcn= 'dividerand'; % divide the data randomly 
    net.divideParam.trainRatio= 0.7; % we use 70% of the data for training 
    net.divideParam.valRatio= 0.3; % 30% is for validation
    net.divideParam.testRatio= 0; % 0% for testing
    net = train(net,t,x);
    plot(t,x,t,net(t));
    

    这里是一个手动数据划分的例子:

    net.divideFcn= 'divideind'; % divide the data manually
    net.divideParam.trainInd= 1:100; % training data indices 
    net.divideParam.valInd= 101:140; % validation data indices 
    net.divideParam.testInd= 141:161;  % testing data indices 
    

    【讨论】:

    • 因为我将“x”作为输入变量并对应于该输入变量,所以我有“y”目标变量。那么在选择“除数”时,两个变量将同时被除,还是分别随机分配?
    • 当然,同时。把它们分开是没有意义的。
    猜你喜欢
    • 2010-11-20
    • 1970-01-01
    • 2015-08-13
    • 2012-12-04
    • 2017-08-18
    • 2015-10-28
    • 2011-07-25
    • 2011-04-07
    • 1970-01-01
    相关资源
    最近更新 更多