Part 2 Lesson 9 wiki


#496

still have version 0.3


#497

I think the problem I’m seeing has been solved with v0.4, there were some issues with byteTensor and they added it’s support in that. Cause I have tried removing all instances from cpu, put everything on gpu, Didn’t quite work out. Could you share the working notebook which you yourself have tried ?


(Michael) #498

I had a similar problem in the pascal notebook with pytorch 0.4.1 and I was able to fix it with two changes:

1.) In the function “detn_loss” and “detn_l1” change “F.sigmoid” to “torch.sigmoid” to avoid the errors during learn.lr_find() and learn.fit(). (This is not a problem but the output looks much better.)

2.) The learn.fit() was always throwing an error when calculating the metrics:
Expected object of type torch.LongTensor but found type torch.cuda.LongTensor for argument #2 'other'
This I could fix with copying the accuracy_np function into the notebook and adapting it to this (after the # you see the original version):

def accuracy_np(preds, targs):
    preds = np.argmax(preds, 1)
    return np.mean(to_np((preds==targs.cpu()))) # (preds==targs).mean()

Here you also see the nice info from the debugger (started with “%debug” in a cell):

> <ipython-input-199-b9616952fd70>(3)accuracy_np()
      1 def accuracy_np(preds, targs):
      2     preds = np.argmax(preds, 1)
----> 3     return np.mean(to_np((preds==targs))) # (preds==targs).mean()

ipdb> p preds
tensor([14, 17,  2, 14, 14,  6, 13,  8,  2,  9, 15,  6, 17,  7, 12,  0, 14, 14,
         7, 19,  1, 14, 14, 13, 14, 14, 14,  6,  9, 18, 13,  0,  2,  6, 18, 11,
        14,  6,  0, 10,  6, 13, 12, 14,  3, 13, 14,  7, 14, 13,  9, 14, 13,  2,
        14, 11,  6,  0,  2,  2,  2, 14, 14,  9])
ipdb> p targs
tensor([14, 17,  2, 14, 14,  5, 13, 10,  2,  9, 15,  6,  8,  7, 12,  0, 14, 14,
         7, 19,  1, 14, 14, 13, 14, 14, 14,  5,  9, 18, 13,  0,  2,  6, 18, 11,
        14,  3,  0, 10,  6, 13, 12, 14,  3, 13, 14,  7, 12, 13,  9, 14,  1,  2,
        14, 11,  6,  0,  2,  2,  2, 17, 14,  9], device='cuda:0')
ipdb> p preds==targs
*** RuntimeError: Expected object of type torch.LongTensor but found type torch.cuda.LongTensor for argument #2 'other'
ipdb> p preds==targs.cpu()
tensor([1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
        1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
        0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1], dtype=torch.uint8)
ipdb> p to_np(preds==targs.cpu())
array([1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
       1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1], dtype=uint8)
ipdb> p np.mean(to_np((preds==targs.cpu())))
0.875
ipdb> q

Maybe the debugging overview helps somebody not familiar with it.

Best regards
Michael


(Jeremy K) #499

Around 20:36 I was looking at the head_reg4 and was wondering why we output 256 features from the Linear layer. Could someone explain or refer me to a source on how I go about choosing input and output features please?


(Masaki Kozuki) #500

This helped me a lot.
Thank you!!!


#501

I got the same error multiple times. I have to replace .cpu() to .cuda() at every line to get rid of the error.


#502

For multibox detection, when we one-hot encode the labels, if the ground truth is only background the vector will be full of zeros, so any vector of activations will give a cross entropy loss of zero… isn’t that a big problem ?


#503

@ guptapankaj1993 I am having the same problem, did you find any solution?


(Pankaj Gupta) #504

@Mihar For getting my work running, I used try-except to ignore those erroneous instances.


(Sanjay Yadav) #505

@jeremy
why we need to multiply sigmoid to 224 in detn_loss , when we already augmented the input bbox coordinates (tfm_y=TfmType.COORD ) which make them fall between the range 0 to 224 ?


(Vishal ) #506

Around 1:04 in the lesson, @jeremy explains how to convert the activations to bounding boxes. The function in the notebook is actn_to_bb(). Can someone please explain what is going on there?


(Mayank Khanduja) #507


Why is it showing aeroplane at top left of all images with ground truth boxes ?


(Eddie) #508

I was getting this same thing, but didn’t dig enough in to it to find out…


(Laurent) #509

I wrote a piece that makes an attempt to explain SSD Multibox in less technical terms. Radek looked through it and seemed to think it was okay, so I’ve added it to the wiki post: SSD Multibox in plain English, I hope that’s okay.
In case anyone would have more feedback, I would be happy to hear it!