Skip to content

Mutability of variational state parameters. #1893

Answered by PhilipVinc
skhaleefah asked this question in Q&A
Discussion options

You must be logged in to vote

I think the documentation is correct in general. See the following example

In [18]: a = {'a': { 'b':1}}

In [19]: a_copy=a.copy()

In [20]: a['a']['b']=2

In [21]: a_copy
Out[21]: {'a': {'b': 2}}

In [22]: a_flax_copy=flax.core.copy(a, {})

In [23]: a['a']['b']=3

In [24]: a_flax_copy
Out[24]: {'a': {'b': 2}}

However, for the particular case you considered, NetKet is trying hard to ensure you do not modify the parameters within vs.parametersdirectly, and internally returns you a copy obtained with flax.core.copy of the parameters.
See

return fcore.copy(self._parameters, {})

This is because the variational state, to work correc…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by PhilipVinc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1891 on August 19, 2024 10:18.