Reputation: 303
I'm trying to finetune the imagenet-vgg-f net in matlab using the matconvnet package. Instead of 1000 classes it shall only be able to classify two.
If I only change the very last layer from 1000 to 2 output neurons everything work's out well. If I, however, add one (or more) additional (fully connected) layers in front of the last layer, the network doensn't converge. It starts with an evaluation error of 0.369 and stays there for all training epochs. It turns out that 0.369 is exactely the portion of class 2 images that I have in my dataset. So the net always says class 1.
net= load('imagenet-vgg-f.mat') ;
f=1/100;
net.layers{end-1} = struct('type', 'conv', ....
'weights', {{f*randn(1,1,4096,24, 'single'), zeros(1, 24, 'single')}}, ...
'stride', 1, ...
'pad', 0, ...
'name', 'fc8') ;
net.layers{end}=struct('type', 'relu') ;
net.layers{end+1}=struct('type', 'conv', ...
'weights', {{f*randn(1,1,24,2, 'single'), zeros(1, 2,'single')}}, ...
'stride', 1, ...
'pad', 0, ...
'name', 'fc8') ;
net.layers{end+1} = struct('type', 'softmaxloss') ;
I am training with the deployed cnn_train.m using a momentum of 0.9 and a learning rate of .001. Altering those parameter did not help to kick of the learning process. I also tried sigmoid activation fcts instead of relu but that didn't help either.
Any idea what I am doing wrong? Especially considering the fact that everything works out perfectly fine when I don't go from 4096 to 24 to 2 but directly from 4096 to 2 neurons.
Thanks in advance
Jonas
Upvotes: 1
Views: 105