pytorch-YOLO-v1 icon indicating copy to clipboard operation
pytorch-YOLO-v1 copied to clipboard

I don't konw where is wrong

Open ladybirdhui opened this issue 6 years ago • 2 comments

i use pytorch1.0 I encountered some warnings and errors. I don't know if they are important .Maybe when i tried to correct them the logic is wrong here are the warnings and errors

1 UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead. I replaced F.sigmoid() with torch,sigmoid in resnet_yolo.py and net.py 2 UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead. I replaced size_average=False with reduction='sum' in yoloLoss.py 3 IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number I replaced loss.data[0] with loss.item() in train.py 4 UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead. images = Variable(images,volatile=True) i just change it to images = images.detach() i don't konw if it's right

My result is bad . so anyone can tell me why thanks

ladybirdhui avatar Mar 16 '19 01:03 ladybirdhui

Hi, this code in repo is implemented by <pytorch 1.0, so some code in old version pytorch(such as pytorch 0.4) have been deprecated, you should change your code by using pytorch 1.0

From point 1-3 you're right, but for point 4 is not exactly right, you should change as below: original: images = Variable(images,volatile=True) change to: with torch.no_grad(): images = Variable(image) Only this can you change directly, for ' images.detach()', after you define you variable and feed into your network, and then you don't want to optimize the variable while backward, so you need to detach this variable, and it will happen on evaluation not train, like this way:

#use it during the evaluation output = model(input) image = Variable(images) image.detach()

In conclusion, after you change all code(upon all is just UserWarning, not error), you should run your network fluently, but if you can not get your expected result, please double check you dataloader or hyperparameter, thanks.

RenMao1314 avatar Mar 24 '19 14:03 RenMao1314

after torch0.4, volatile=true was deprecated, you should try 'with torch.no_grad()', or just reduce your batch_size, but it's just not use best of your memory

zkchen95 avatar May 08 '19 10:05 zkchen95