(help) KeyError: 'loss' while trying to use notebook for finetuning on flickr_style

150 views
Skip to first unread message

S.Majid Azimi

unread,
Jul 21, 2015, 8:46:58 PM7/21/15
to Caffe Users
Hi 

I am trying to use finetuning notebook

Fine-tuning a Pretrained Network for Style Recognition

 but whenever it reached following line it gives the error KeyError: 'loss'

train_loss[it] = solver.net.blobs['loss'].data


I don't know what to do. please help me if you what it means?

S.Majid Azimi

unread,
Jul 22, 2015, 5:43:47 AM7/22/15
to Caffe Users

It's been a few days that I've started working with cnns and caffe =>newbie!
I'm trying to use fine-tuning notebook provided in the examples folder.

running the exact same notebook I'm getting the error:
KeyError: 'loss'

for the code line:


train_loss[it] = solver.net.blobs['loss'].data

after investigating the blobs.key using:

solver.net.blobs.keys()

i see the following configuration:
['data',
'label',
'conv1',
'pool1',
'norm1',
'conv2',
'pool2',
'norm2',
'conv3',
'conv4',
'conv5',
'pool5',
'fc6',
'fc7',
'fc8_flickr',
'(automatic)']

I see (automatic) after fc7-flickr which is strange because I don't see this layer neither in deploy.prototxt nor train-val.prototxt.

I changed the 'loss' to '(automatic)' and no longer the error , but the results are not the same. I got this result:

Accuracy for fine-tuning: 0.250000002235
Accuracy for training from scratch: 0.0399999994785
and iteration outputs:

iter 0, finetune_loss=3.820410, scratch_loss=3.389356
iter 10, finetune_loss=3.713553, scratch_loss=19.500618
iter 20, finetune_loss=3.163069, scratch_loss=2.997965
iter 30, finetune_loss=2.911142, scratch_loss=3.048755
iter 40, finetune_loss=2.649367, scratch_loss=3.131553
iter 50, finetune_loss=2.413907, scratch_loss=3.171020
iter 60, finetune_loss=2.922716, scratch_loss=2.992927
iter 70, finetune_loss=2.501048, scratch_loss=3.010788
iter 80, finetune_loss=1.944367, scratch_loss=3.025702
iter 90, finetune_loss=2.152704, scratch_loss=2.970715
iter 100, finetune_loss=2.071161, scratch_loss=3.039460
iter 110, finetune_loss=1.738475, scratch_loss=2.996681
iter 120, finetune_loss=1.874542, scratch_loss=2.987170
iter 130, finetune_loss=1.809107, scratch_loss=3.016882
iter 140, finetune_loss=2.044318, scratch_loss=2.983100
iter 150, finetune_loss=2.178490, scratch_loss=3.020104
iter 160, finetune_loss=1.958706, scratch_loss=2.972355
iter 170, finetune_loss=1.757214, scratch_loss=2.990436
iter 180, finetune_loss=1.293990, scratch_loss=3.015960
iter 190, finetune_loss=1.825832, scratch_loss=3.031480
done

what is the problem in this case?

S.Majid Azimi

unread,
Jul 22, 2015, 11:33:25 AM7/22/15
to Caffe Users
 I have changed the model from caffenet to alexnet I get the error of kernel has died in the jupyter ipython notebook. 
what is the problem?
I really appreciate if someone helps me.
thanks

On Wednesday, 22 July 2015 02:46:58 UTC+2, S.Majid Azimi wrote:

S.Majid Azimi

unread,
Jul 22, 2015, 3:44:59 PM7/22/15
to Caffe Users

the problem was solved,

it was caused due to uncompleted downloaded caffe-master which by redownloading and replacing the train_val.prototxt the problem was solved and there is no (automatic) layer in blobs.keys.


On Wednesday, 22 July 2015 02:46:58 UTC+2, S.Majid Azimi wrote:
Reply all
Reply to author
Forward
0 new messages