found the the exact same question on SO:

  

      stackoverflow.com
  

  
      
    
  


  Difference between src_mask and src_key_padding_mask 16



  pytorch, transformer



  asked by
  
  
    Leo
  
  on 10:18AM - 03 Jun 20 UTC


  

  
    
    
  

  


more related links:

  
      

      reddit
  

  
    

r/pytorch - [Transformer] Difference between src_mask and src_key_padding_mask 6

  0 votes and 0 comments so far on Reddit


  

  
    
    
  

  



  

      stackoverflow.com
  

  
      
    
  


  TransformerEncoder with a padding mask 7



  pytorch, transformer, attention-model



  asked by
  
  
    Pourya Vakilipourtakalou
  
  on 12:43AM - 16 Jun 20 UTC


  

  
    
    
  

  



perhaps reading the docs for MHA is the best option:
https://pytorch.org/docs/master/generated/torch.nn.MultiheadAttention.html#torch.nn.MultiheadAttention 4