Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I don't konw where is wrong #17

Open
ladybirdhui opened this issue Mar 16, 2019 · 2 comments
Open

I don't konw where is wrong #17

ladybirdhui opened this issue Mar 16, 2019 · 2 comments

Comments

@ladybirdhui
Copy link

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

@RenMao1314
Copy link

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.

@zkchen95
Copy link

zkchen95 commented May 8, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants