Is stumbled upon the same issue and found an answer here on Stack Overflow:
  
      stackoverflow.com
  
  
      
    
  

  Maybe I found something strange on pytorch, which result in property setter not working 25



  python, pytorch, setter



  asked by
  
  
    Weiming Xiong
  
  on 07:57AM - 09 Apr 20 UTC


  
  
    
    
  
  


As far as I understand this is the basic cause: Since nn.Module implements a __settatr__() method that doesn’t call the builtin __settattr__ in the case that the attribute you try to set is a itself a nn.Module the property setter is never executed. For other attributes that are not some PyTorch specific types (check the implementation for details: pytorch/module.py at eab59bae15bda508cdfbbc69a1a761b2b2c3780b · pytorch/pytorch · GitHub 7) the setter should work as usual.