so not related to this?
The reason i ask is what if (rather when)google fixes that bug then how do we run it ?
Iām unsure. Probably choose a smaller image size for your transfer image. Or shrink it down via a transform (since it is a TensorImage).
To the no_grad and eval, no. See above discussion where I said why their different.
No_grad never updates for evaluation weights. Only gradients. And vice versa
oh shoot yeah.
Thatās why I brought it into further discussion, very easy to get confused
So to lay this out:
We are using vgg19 to calc the feature loss. We are using a pre-trained model so all the weights are calc.
We are using vgg19 in inference mode ie .eval
(to calc the activation at different layers).
The purpose of .eval
is to appropriately change the behaviour of bn and dropout layers. But our vgg19 doesnāt have any of those? (so why is .eval
being used ? ) is
.eval
effecting something else ?
Because by default a model is in model.train
mode so we use .eval
to change the mode.
no_grad
can be used with .eval
for saving space. (they CAN"T be used interchangeably)
model.train() and model.eval() do not change any behavior of the gradient calculations.
model.eval()
for batch in val_loader:
#some code
vs
model.eval()
with torch.no_grad():
for batch in val_loader:
#some code
The first approach is enough to get correct results. The second approach will additionally save some memory.
@muellerzr am i missing anything? please edit it if i am
Thanks.
Iām not sure, but eval already disables grad. Thatsā the major diffence between modes. So, no need to additionally disable it - mentioned either on forums or lecturesā¦
It doesnāt. (See the very last post on that thread). Itās still calculated. We can disable it to save memory.
Now for a bigger question which could help us all explore the code:
What does get_preds in fastai2 default to doing? For where to start, check Learner.py
Still donāt understand a use case where you would want to calc gradients in the eval mode though
The answer (Atleast for learn.validate()) is we donāt calculate the gradients:
So we can see on GatherPredsCallback during begin_validate we see the model set to eval:
Later, if we go look at _do_epoch_validate (on Learner), we find our with torch.no_grad():
Just to clarify-
You mean during evaluation we set it in eval mode and turn off grad calculations right ?
Correct Iāll put that in real quick
Edited the post before this
Video for tonight
Yes, the category ids are not continuous so sorting them out as @muellerzr will unfortunately not work. Right now I am just ignoring the category ids - getting the mask - mapping back the mask to the correct category id⦠it works but it feels very inefficientā¦
Thanks guys for joining!
A few notes from today:
Jeremyās Object Detection Lesson: here
RetinaNet Paper: here
Relevant source code for predictions (may break, have not looked at this for a few days): here
Single Point Regression (headpose): here
(remind me if thereās anything else I missed to link)
One thing not mentioned was the heatmap that Iāve spoken about. This is due to I was not able to successfully train the model well. However, if it is of interest I can release the source code and do a quick walk through video describing the technique and how I went about the dataloader if people would be interested. Let me know
Replying to let you know Iām interested
@muellerzr I donāt understand how fastai2 decides to apply transforms, I mean for Keypoint regression if input is transformed the output should also be transformed, For example, If Resize is applied as item_tfms, the output is transformed by the same function?, or how is that handled?, lets say if my input is a rotated image and output is always a straight image, In this case I just want to apply rotation only to my inputs, how would I do that?
Yes. If we think about keypoints we need to adjust our yās along with it, remember our KeypointScalar transform we made a few lessons back. The transforms are run by TypeDispatch, where if we use a transform, if our input is what that transform is expecting, it will run it. IE Resize for instance looks like so (not exact but close):
class Resize():
def encodes(x:[TensorPoint, TensorImage])
Got it! But what if I need my input images to be transformed but not the output image, how would I do that?