I made it.
Assumption
The input is LongTensor which contains indices for embedding as shape has (batchsize, N * N).
In default, embedded value is 0 if index is 0. If you want to change this index, change “padding_idx” any number.
The output is adjacency sparse matrix as shape has (batchsize, N, N).

D9B79EA1-8FB1-4D6B-B5DF-C2EE52B2571E.jpeg1668×1456 368 KB


  
      
      GitHub
  
  
    

shllln/SparseEmbedding 14

Sparse Embedding For Pytorch. Contribute to shllln/SparseEmbedding development by creating an account on GitHub.


  
  
    
    
  
  


thank you.