I quickly read your code and i saw a small problem as i understand you try to predict 16-length array
ex.
Input: [  1.,   2.,   3.,  …,  14.,  15.,  16.]
Output: [  2.,   3.,   4.,  …,  15.,  16.,  17.]
Transformer model take input shape as (Seq lenght, Batch size, Features) for ex. i have a 10 word sequence and i need to predict 11th word in the sequence my input shape have to be (10, 1, feature_size)
Please correct if I misunderstood your input output shape
These tutorials can help you:

  
      pytorch.org
  
  
    

Sequence-to-Sequence Modeling with nn.Transformer and TorchText — PyTorch... 63



  
  
    
    
  
  



  
      
      GitHub
  
  
    

pytorch/examples 31

A set of examples around pytorch in Vision, Text, Reinforcement Learning, etc. - pytorch/examples