Hi @general,
Would you be able to share with us a reproducible code so we can debug it? I believe another user has reported this here:

  

      github.com/pytorch/opacus
  

  
    
  
	  
  

  
    
      Getting "ValueError: Unexpected grad_sample type: <class 'NoneType'>" for self-supervised training. 4
    

    
      
        opened 
        
          
        
        Dec 12, 2021
      
      


      
        
          
          vangorade
        
      
    

    
    
  


  
    Congratulations on the new opacus version release!

I am trying to train a con…trastive learning model on time-series data with opacus version 1.0 by following the official [tutorial ](https://github.com/pytorch/opacus/blob/main/tutorials/building_image_classifier.ipynb).

Error:
"ValueError: Unexpected grad_sample type: <class 'NoneType'>"

Full error:
    model_optimizer.step()  -> error starts from this line in my code.
  File "/mnt/f/AI_research/TS-TCC-main/opacus/opacus/optimizers/optimizer.py", line 478, in step
    if self.pre_step():
  File "/mnt/f/AI_research/TS-TCC-main/opacus/opacus/optimizers/optimizer.py", line 459, in pre_step
    self.clip_and_accumulate()
  File "/mnt/f/AI_research/TS-TCC-main/opacus/opacus/optimizers/optimizer.py", line 366, in clip_and_accumulate      
    g.view(len(g), -1).norm(2, dim=-1) for g in self.grad_samples
  File "/mnt/f/AI_research/TS-TCC-main/opacus/opacus/optimizers/optimizer.py", line 313, in grad_samples
    ret.append(_get_flat_grad_sample(p))
  File "/mnt/f/AI_research/TS-TCC-main/opacus/opacus/optimizers/optimizer.py", line 186, in _get_flat_grad_sample    
    raise ValueError(f"Unexpected grad_sample type: {type(p.grad_sample)}")
ValueError: Unexpected grad_sample type: <class 'NoneType'>

Thank you.