InnovArul:

Try passing self.custom_value without .item(). i.e., pass the reference of the object so that if you change the values, it gets reflected in self.conv_1.


I tried that already but unfortunately, it then passes it as a paramter to my layer so then I need to also add MyConv2D.custom_value as well, which would just be a copy of the same custom_value in each layer, which is why I tried to only pass the value instead of the parameter.



 InnovArul:

Instead of dealing with state_dict, why not create a method to set custom_value dynamically?
and set it as self.custom_value[0] = <new val> without creating new tensor.


Could you please elaborate on this a bit? so this method would just return the value I want to set? Where should I call this line? Before I run my network? And for this, would it be OK if I made custom_value just a tensor and not a parameter (since it doesn’t need grad anyway).