Matlab에 매우 큰 기차 세트가 있습니다. 그리고 대규모 훈련이 필요합니다.
훈련 세트를 여러 부분으로 분할하고 네트워크를 반복적으로 훈련하고 각 반복에서 "net"을 덮어 쓰는 대신 업데이트 할 수 있습니까?
아래 코드는 아이디어를 보여 주지만 작동하지 않습니다. 각 반복에서 훈련 된 데이터 세트에 따라 넷을 업데이트합니다.
TF1 = 'tansig';TF2 = 'tansig'; TF3 = 'tansig';% layers of the transfer function , TF3 transfer function for the output layers
net = newff(trainSamples.P,trainSamples.T,[NodeNum1,NodeNum2,NodeOutput],{TF1 TF2 TF3},'traingdx');% Network created
net.trainfcn = 'traingdm' ; %'traingdm';
net.trainParam.epochs = 1000;
net.trainParam.min_grad = 0;
net.trainParam.max_fail = 2000; %large value for infinity
while(1) // iteratively takes 10 data point at a time.
p %=> get updated with following 10 new data points
t %=> get updated with following 10 new data points
[net,tr] = train(net, p, t,[], []);
end
다음은 matlab에서 NN을 반복적으로 (미니 배치) 훈련하는 방법의 예입니다.
장난감 데이터 셋을 생성하세요
[ x,t] = building_dataset;
미니 배치 크기 및 수
M = 420
imax = 10;
직접 훈련과 미니 배치 훈련을 확인할 수 있습니다.
net = feedforwardnet(70,'trainscg');
dnet = feedforwardnet(70,'trainscg');
표준 교육 : 전체 데이터를 사용하는 단일 호출
dnet.trainParam.epochs=100;
[ dnet tr y ] = train( dnet, x, t ,'useGPU','only','showResources','no');
오류 측정 : MEA, 측정하기 쉬운 MSE 또는 원하는 기타
dperf = mean(mean(abs(t-dnet(x))))
이것은 반복적 인 부분입니다 : 호출 당 1 epoch
net.trainParam.epochs=1;
e=1;
에포크 비교를 위해 이전 메서드 오류에 도달 할 때까지
while perf(end)>dperf
각 시대에서 데이터를 무작위 화하는 것이 매우 중요합니다 !!
idx = randperm(size(x,2));
모든 데이터 청크로 반복적으로 훈련
for i=1:imax
k = idx(1+M*(i-1) : M*i);
[ net tr ] = train( net, x( : , k ), t( : , k ) );
end
각 시대의 성능을 계산
perf(e) = mean(mean(abs(t-net(x))))
e=e+1;
end
성능을 확인하고 곡선과 같은 멋진 준 부드러움과 exp (-x)를 원합니다.
plot(perf)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다