I want to raise again an issue with parameters the discussion for which was postponed in #1680.
Here's a use case which I want to support:
model=MyModel(param1=np.array([[1,2], [3.,4]]), param2= 4.5, param_dim=1)
This used to work, #1086 broke it, #1680 partially fixed it but introduced new behaviour, namely this is now allowed:
model = MyModel(param1=[[1,2], [2,3]], param2=100, param_dim=2)
In the second example the value of pram2 is repeated param_dim times.
Any reason not to have the first example allowed (it raises an error)?
Part of the problem is that Parameter.__set__ is used to set the initial value of a parameter as well as to update a parameter value. For the second use case it needs to verify that the shape of the new value is the same as the shape of the old one. But it does this verification in the first use case as well, before the shape has been determined.
@embray Any suggestions how to fix this?
I want to raise again an issue with parameters the discussion for which was postponed in #1680.
Here's a use case which I want to support:
model=MyModel(param1=np.array([[1,2], [3.,4]]), param2= 4.5, param_dim=1)This used to work, #1086 broke it, #1680 partially fixed it but introduced new behaviour, namely this is now allowed:
model = MyModel(param1=[[1,2], [2,3]], param2=100, param_dim=2)In the second example the value of pram2 is repeated
param_dimtimes.Any reason not to have the first example allowed (it raises an error)?
Part of the problem is that
Parameter.__set__is used to set the initial value of a parameter as well as to update a parameter value. For the second use case it needs to verify that the shape of the new value is the same as the shape of the old one. But it does this verification in the first use case as well, before the shape has been determined.@embray Any suggestions how to fix this?