Part 2 Lesson 9 wiki

(Kevin Bird) #365

I’m working on the defaultdict thing and I get what it is doing now that I’m breaking everything down, I just have a question on lambda (I know, not technically related to defaultdict). Is there a way to put lambda:x+1 so what I’m wanting x to be is I want that to be whatever the key is. so

trn_anno = collections.defaultdict(lambda:x+1)

would look like this:

trn_anno[12] would give you 13 is that a thing you can do with lambda?

I’ve tried to google it, but I haven’t seen anything that does this.

(Hiromi Suenaga) #366

It is possible to create a lambda function that increments the input by 1 :

my_lambda = lambda x: x + 1

I am not sure the use case you have in your mind, but you probably don’t want to put that in defaultdict. The reason is, if say trn_anno[12] doesn’t exist, it calls the lambda function with no argument and the call will fail because it didn’t pass the required parameter. I might be able to help more if you could explain what you are trying to do. Sorry :frowning:

(Kevin Bird) #367

well, my thought is that we are using this to say what the default is so my thought was that if they key had something to do with the value. so let’s say I want to make a lookup table with a list of the squares and I only want to calculate them once and then I want to use the dictionary. So my defaultdict function would be: squares = collections.defaultdict(lambda x:x**2). The reason I’m thinking this could be useful is in embedded systems when you don’t have much space, you could still have the speed of a lookup table without having to store the whole table. So when I use this defaultdict, I now want to call squares[5] which should give me 25, but I don’t know how to pass the key through if that makes sense.

(Sarada Lee) #368

Done. Now, I can see the gamma value in relation to the loss.

(Hiromi Suenaga) #369

Sounds like you are trying to implement a cache mechanism. I am not familiar with what kind of approaches people use in Python though :confused:

(Kevin Bird) #370

No problem. I don’t think it’s important for this anyways.

(Phani Srikanth) #371

I think what you’re for looking is available here. I quickly tested it and it seems to work.

(Mike Kunz ) #372

Hiromi- thanks for putting this together!!!

(Hiromi Suenaga) #373

Sure :slight_smile: It’s just some scribble I did a while ago.

(Emil) #374

There is a LRU cache decorator in the standard library.

(Chloe Sultan) #375

Dovetailing with @daveluo 's awesome whiteboarding of SSD_MultiHead (thank you for that!) - I also found it really helpful to spend time diagramming / visualizing the forward line-by-line. Attaching screenshot here in case helpful for anyone else…

On documenting the shapes/size of arrays/tensors being passed to methods of FastAI
(Vibhutha Kumarage) #376

Hey Guys,
For those who want a quick recap on Cross-Entropy watch this youtube video

(Jeremy Howard) #377

I’d love to show that in class (with credit of course!) - would that be OK? If so, would you prefer me to credit your forum user name, or your real name (if the latter, please tell me your real name)?

(Vibhutha Kumarage) #378

Hey everyone…
I faced a problem when I’m reading the SSD paper :sweat: … Can anyone tell me how Detections: 8732 per class is calculated in the SSD network?.. :slightly_smiling_face:

Thank you… :slight_smile:

(Jeremy Howard) #379

Sure! But you try first :slight_smile: How many detections do you calculate based on what you’ve read? Take us through your thinking and we’ll figure this out together.

(Aleksandr) #380

Hey everyone.
I think, I found a little bug in pascal-multi.ipynb.
It is a peace of code in the very beginning when we predict multiple classes and plot pictures with one or more predicted labels:

for i,ax in enumerate(axes.flat):
    ya = np.nonzero(y[i]>0.4)[0]
    b = '\n'.join(md.classes[o] for o in ya)
    ax = show_img(ima, ax=ax)
    draw_text(ax, (0,0), b)

I found, that ya = np.nonzero(y[i]>0.4)[0] is one object and the code always plots only one class instead of several.
So I removed [0] and added int(o) (to convert from torch.cuda.LongTensor dtype) in b definition. Like this

for i,ax in enumerate(axes.flat):
    ya = np.nonzero(y[i]>0.4)
    b = '\n'.join(md.classes[int(o)] for o in ya)
    ax = show_img(ima, ax=ax)
    draw_text(ax, (0,0), b)

Now it works well.
Should I create a pull request for this?

(Pavel Surmenok) #381

What is the best way to deal with images with a different aspect ratio? For example, I have a dataset with images of size 375x1242. Width is 3.3 times larger than height. Resizing the images to a square shape expected by pretrained Imagenet models will lead to unrealistically looking images.
Is there any way to leverage pretrained image classification models in this case, or it’s better to create SSD model with an appropriate aspect ratio and train it from scratch?

(Santhanam Elumalai) #382

Good list of Criterions for better understanding

(Francisco Ingham) #383

This is great! Just as clarifying statement, if someone had the same doubt as me. If you are wondering why do we have an extra output for background (20 + 1), refer to this:

(Bart Fish) #384

I was never able to get my verification loss much below 10, but changing the bias from -4 to -3 worked much better in terms of the suppression of false positives.