mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

Any Help with the lstm_unroll Model in lstm.py?

Open KCHWang opened this issue 10 years ago • 5 comments

I am reading the code in example/rnn/lstm.py. Could someone please explain what the last few lines are doing? Are we some how reshape label, which is a symbol here? Many thanks!

**################################################################################
# Make label the same shape as our produced data path
# I did not observe big speed difference between the following two ways

label = mx.sym.transpose(data=label)
label = mx.sym.Reshape(data=label, target_shape=(0,))

#label_slice = mx.sym.SliceChannel(data=label, num_outputs=seq_len)
#label = [label_slice[t] for t in range(seq_len)]
#label = mx.sym.Concat(*label, dim=0)
#label = mx.sym.Reshape(data=label, target_shape=(0,))
################################################################################**

KCHWang avatar Jul 14 '16 10:07 KCHWang

@KCHWang The code is trying to squeeze the labels into a single vector.

sxjscience avatar Jul 14 '16 15:07 sxjscience

@sxjscience Thanks! I understand that is what label = mx.sym.Reshape(data=label, target_shape=(0,)) is doing. But what about label = mx.sym.transpose(data=label)? I am confused about the transpose function. Any hint please?

KCHWang avatar Jul 15 '16 01:07 KCHWang

Sequential Consistency, 保持预测结果与标签顺序一致,

wushouchuan avatar Jul 15 '16 03:07 wushouchuan

@KCHWang I met a same problem with you when I run lstmocr.py with my own data(number=18), occur following error:

 Traceback(msot recent call last):
    File "lstm_ocr.py",line 165,in <module>
     batch_end_callback=mx.callback.Speedometer(BATCHSIZE,50))
   File "../../python/mxnet/model.py",line 745,in fit
     self._init_params(dict(data.provide_data+data.provide_label))
   File "../..python/mxnet/model.py",line 486,in _init_params 
     assert(arg_shapes is not None)
AssertionError

can you show me the iterator that you do yourself? I have no idea to deal with my data, thank you!

Yang507 avatar Jul 15 '16 08:07 Yang507

I have the same question. Do you have a solution? How to train my own data in the lstm?

lyndd avatar Nov 02 '16 12:11 lyndd