How to add a regression layer at the end of an existing CNN?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi
I have been trying to use transfer learning with a regression layer at the end. However, I end up with NaNs when I try to predict new images with the ConvNet. How should I put together the layers at the end? Like this?
% Load VGG network
net = vgg19;
% Remove last 3 layers.
layersTransfer = net.Layers(1:end-3);
% Add a fully connected layer and a regression layer
layers = [layersTransfer
fullyConnectedLayer(1)
regressionLayer];
% Training options
transferLayerOptions = trainingOptions('sgdm','MiniBatchSize',25,...
'InitialLearnRate',0.001, ...
'MaxEpochs',7, 'Verbose', true);
댓글 수: 2
Birju Patel
2017년 7월 20일
What happened during training? Did you see NaNs printed in the training log printed in the command window? If so, it's likely your learning rate is too high.
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!