How to add a regression layer at the end of an existing CNN?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Tobias Pahlberg
il 29 Mag 2017
Risposto: Tobias Pahlberg
il 6 Ott 2017
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 Commenti
Birju Patel
il 20 Lug 2017
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.
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Image Data Workflows in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!