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

Fixed double-counting of parameters when a module is referenced in more than one way. #534

Merged
merged 1 commit into from
Feb 23, 2022

Conversation

NiklasGustafsson
Copy link
Contributor

No description provided.

Comment on lines 474 to 477
foreach (var (n, p) in sm.named_parameters(true)) {
if (seen.Contains(p.Handle)) continue;
seen.Add(p.Handle);
yield return ($"{name}.{n}", p);
Copy link
Contributor

@lostmsu lostmsu Feb 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seen should be passed recursively

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that would be more efficient, but it shouldn't affect the result. I'll have to create a non-public member for it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I did not notice it was not actually a counting function, but a parameter enumerator.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still a good idea to pass it down for efficiency.

@NiklasGustafsson
Copy link
Contributor Author

@Metritutus -- thanks for the issue, it allowed me to find and fix a significant error in the implementation of Module.parameters()!

@NiklasGustafsson NiklasGustafsson merged commit e21546d into dotnet:main Feb 23, 2022
@NiklasGustafsson NiklasGustafsson deleted the bug532 branch August 5, 2022 14:12
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 this pull request may close these issues.

Why does storing module layers in arrays break the learning process?
2 participants