我需要在matlab中训练模式识别网络。我有几个数据集将用于培训。我的脚本看起来像这样:
%%% train network with a couple of datasets
pathStr = 'Daten_Training';
files = dir(sprintf('%s/*.mat',pathStr));
for k = 1:length(files)
%%% load data for training
load(sprintf('%s/%s',pathStr, files(k).name));
%%% manually set targets to train the network with
Targets = setTargets(Data);
%%% create and train neural network
% Create a Pattern Recognition Network
hiddenLayerSize = 20;
net = patternnet(hiddenLayerSize);
% Train the network with our Data
net = trainNetwork(net,Data,Targets);
end
trainNetwork
函数如下所示:
function [ net ] = trainNetwork( net, Data, Targets )
% calculate features
[Features, TargetsBlock, blockIdx] = calcFeatures_Training(Data, Targets);
% split data for training
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the network
[net, tr] = train(net, Features, TargetsBlock);
end
有没有办法用相同的结果进行多次训练,好像我会连续使用一次训练和所有数据集一样? 现在,看起来网络只是用新数据重新训练,之前的一切都丢失了。
答案 0 :(得分:0)
现在不现实与否,但也许对某人有所帮助。
您只能训练网络一次。如果您再次训练,它将成为一个新的网络。 :)权重将有所不同。如果输入相同的名称,则每次运行脚本时,MATLAB都会覆盖。
我认为最好的方法是:
希望这对某人有帮助:)