You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/06/28 19:50:36 UTC

[GitHub] altosaar edited a comment on issue #9257: No padding idx arg in gluon.nn.Embedding

altosaar edited a comment on issue #9257: No padding idx arg in gluon.nn.Embedding
URL: https://github.com/apache/incubator-mxnet/issues/9257#issuecomment-401128384
 
 
   This would be a nice feature to have.
   
   Current workaround:
   
   ```
   In [29]: emb = gluon.nn.Embedding(10, 3)
   
   In [30]: emb.initialize()
   
   In [31]: PADDING_IDX = 9
   
   In [32]: emb.weight._data[0][PADDING_IDX] = 0
   
   In [33]: x = emb(nd.array([PADDING_IDX]))
   
   # do stuff with embeddings. after every gradient update, need to set the padding embedding back to zero using `emb.weight._data[0][PADDING_IDX] = 0`.
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services