mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

onehot_encode dense format ?

Open Kublai-Jing opened this issue 11 years ago • 8 comments

Hi mxnet,

It seems that the current implementation of onehot_encode is to convert the indices to a DENSE one-hot representation. Should we change it to represent directly the embedding ?

Right now it seems that handle it using numpy directly and feed that embedding into NDArray is more efficient.

Kublai-Jing avatar Oct 25 '15 18:10 Kublai-Jing

Yes! This is something we should do

tqchen avatar Oct 25 '15 19:10 tqchen

Yes, some variant of FullyConnected as Embedding that takes directly one-hot index would be better. Something like this for example.

pluskid avatar Nov 13 '15 16:11 pluskid

where could I start working on this issue ? as what @pluskid suggests ? Current implementation prevents us from creating long sequences lstm (memory will blow)

Kublai-Jing avatar Nov 20 '15 03:11 Kublai-Jing

@Kublai-Jing I am working on taking embeding directly. Will PR back today or tomorrow.

antinucleon avatar Nov 20 '15 04:11 antinucleon

awesome !

Kublai-Jing avatar Nov 20 '15 04:11 Kublai-Jing

After https://github.com/dmlc/mxnet/pull/654 merge, embedding problem seems will be solved.

antinucleon avatar Nov 20 '15 08:11 antinucleon

fixed by #654 Please check updated LSTM examples

tqchen avatar Nov 21 '15 01:11 tqchen

Actually I found that the embedding version is about 2 times slower than the original one. Is that normal ?

Very informal number from my lstm (in seconds): Embedding version: Iter: 0 batch: 0 taking: 0.494634866714 Iter: 0 batch: 1000 taking: 299.334768057

Fully Connected version: Iter: 0 batch: 0 taking: 0.509057044983 Iter: 0 batch: 1000 taking: 143.694847107

Kublai-Jing avatar Nov 21 '15 03:11 Kublai-Jing