Yes, you have to assign an nn.Parameter to the .weight attribute.
However, I don’t know what exactly caused your issue, as I was getting an error while executing your code (as described before).
I was using the latest nightly release and haven’t tried 1.7.