At first, it seems after cloning something, you need to invoke detach:

  
      stackoverflow.com
  
  
      
    
  

  Pytorch preferred way to copy a tensor 11



  copy, pytorch, tensor



  asked by
  
  
    dkv
  
  on 04:51PM - 20 Mar 19 UTC


  
  
    
    
  
  


I have not tried the clone method yet, but “first serialize class to disk, then load it to a new class instantiation” guarantee a safe and clean deep clone. The disadvantage is that it is not high performance compared to a clone API call.