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

AdamW bug on v0.96.0 #516

Closed
QingtaoLi1 opened this issue Feb 14, 2022 · 12 comments · Fixed by #523
Closed

AdamW bug on v0.96.0 #516

QingtaoLi1 opened this issue Feb 14, 2022 · 12 comments · Fixed by #523

Comments

@QingtaoLi1
Copy link

When I update TorchSharp from 0.95.4 to 0.96.0, some exception occurs on torch.optim.AdamW():

System.Runtime.InteropServices.SEHException: 'External component has thrown an exception.'

The only change I commit is lower-casing train() and eval(). Notice that the first argument of torch.optim.AdamW() (and other optimizers) changes from IEnumerable<torch.Tensor> to IEnumerable<TorchSharp.Modules.Parameter>, so I guess the bug is related to library changes to solve #501.

@NiklasGustafsson
Copy link
Contributor

@QingtaoLi1 -- the renaming and the type change should not affect anything. Down in native code, neither matters.

Could you provide the whole stack trace? The one line you have is not enough to give me an idea of what is going on.

@NiklasGustafsson
Copy link
Contributor

Also, in the next release, AdamW will be implemented in managed code, so things are likely to change.

@QingtaoLi1
Copy link
Author

@QingtaoLi1 -- the renaming and the type change should not affect anything. Down in native code, neither matters.

Could you provide the whole stack trace? The one line you have is not enough to give me an idea of what is going on.

Stack trace here. It points to the constructor of Adam and nothing else. The only error message is "external component..." I showed above.
image
image

@NiklasGustafsson
Copy link
Contributor

Okay, thanks!

@QingtaoLi1
Copy link
Author

@NiklasGustafsson Oh I didn't notice I was captioning the error of Adam. But the exception is the same for both optimizers.

@NiklasGustafsson
Copy link
Contributor

Let's see how this changes with the new implementation in 0.96.1

@QingtaoLi1
Copy link
Author

QingtaoLi1 commented Feb 15, 2022

Let's see how this changes with the new implementation in 0.96.1

Great!

P.S. I tried SGD just now and it also fails.

@NiklasGustafsson
Copy link
Contributor

Hmmm. There's something fundamentally wrong. Is there any possibility of any mixup of DLLs or packages?

@QingtaoLi1
Copy link
Author

I'm not sure. Just try deleting .nuget\\packages\\torchsharp\\ and re-installing it, but nothing changes.

@NiklasGustafsson
Copy link
Contributor

NiklasGustafsson commented Feb 15, 2022

OK. Can you try running some of the examples in dotnet/TorchSharpExamples?

@QingtaoLi1
Copy link
Author

QingtaoLi1 commented Feb 15, 2022

@NiklasGustafsson Weird, TorchSharpExamples for AG_NEWS and MNIST can run. I don't find anything different between my code and the examples -- getting parameters by model.parameters() and right then building optimizers using torch.optim.SGD/Adam.

@NiklasGustafsson
Copy link
Contributor

NiklasGustafsson commented Feb 15, 2022

If you have a chance to narrow it down to a smaller example, running with random data, etc., that would be great. Maybe it has something to do with the specific modules you are using?

NiklasGustafsson added a commit to NiklasGustafsson/TorchSharp that referenced this issue Feb 16, 2022
@NiklasGustafsson NiklasGustafsson linked a pull request Feb 18, 2022 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants