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

Support using OrderedDict for initialization, also improve error message #774

Open
sunxd3 opened this issue Jan 6, 2025 · 3 comments
Open

Comments

@sunxd3
Copy link
Member

sunxd3 commented Jan 6, 2025

ref TuringLang/Turing.jl#2452

Support of using NamedTuple for initial_params input was introduced in #632.

Current implementation of set_values!! , which handles the initialization, does not support initializing variables that are subsumed by a varname provided in the NamedTuple.

For example, if the model contains X[1], it won’t work if initial_params is passed as (; X = ...).

To enable this functionality, we could consider adding support for using OrderedDict.

Additionally, as mentioned in TuringLang/Turing.jl#2452 , the error message can be improved when the provided vector does not conform to AbstractVector{<:Union{Real, Missing}}.

@penelopeysm
Copy link
Member

Does it specifically have to be an OrderedDict (as opposed to any ordinary Dict)?

@penelopeysm penelopeysm transferred this issue from TuringLang/Turing.jl Jan 7, 2025
@yebai
Copy link
Member

yebai commented Jan 9, 2025

Does it specifically have to be an OrderedDict (as opposed to any ordinary Dict)?

Yes, this is due to some internal design choices of SimpleVarInfo{OrderedDict}, which was motivated to store the parameters in a specific ordering, IIRC.

@sunxd3
Copy link
Member Author

sunxd3 commented Jan 9, 2025

Does it specifically have to be an OrderedDict

For initialization, probably not. But we would need to check for overlapping of VarNames (the keys of the Dict).

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