mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

How to set parameter of speech demo

Open zhangjiulong opened this issue 10 years ago • 18 comments

I tried using part of ami data, and using the default.cfg and my transform file is like this:

TRANSFORM scp:/home/zhangjl/git/kaldi/egs/ami62_mxnet/s5/exp_mxnet/data-for-mxnet/feats2.scp
scp:/home/zhangjl/git/kaldi/egs/ami62_mxnet/s5/exp_mxnet/data-for-mxnet/post2.scp

then got some error:

Loading data into memory...
ERROR (Input():kaldi-io.cc:742) Error opening input stream TRANSFORM

[ Stack-Trace: ]

I changed transform file to

NO_FEATURE_TRANSFORM scp:/home/zhangjl/git/kaldi/egs/ami62_mxnet/s5/exp_mxnet/data-for-mxnet/feats2.scp
scp:/home/zhangjl/git/kaldi/egs/ami62_mxnet/s5/exp_mxnet/data-for-mxnet/post2.scp

then the following error reported:

Traceback (most recent call last):
  File "train_lstm_proj.py", line 303, in <module>
    do_training(training_method, args, module, data_train, data_val)
  File "train_lstm_proj.py", line 188, in do_training
    for nbatch, data_batch in enumerate(data_train):
  File "/home/zhangjl/git/kaldi/egs/ami62_mxnet/s5/io_util.py", line 410, in __iter__
    np_data_buffer[i][:n_take] = fea_utt[idx_take]
ValueError: could not broadcast input array from shape (20,13) into shape (20,40)

then I modifed default.cfg

xdim =40 changed to xdim = 13

then another error reported:

[14:31:29] /home/zhangjl/git/mxnet/dmlc-core/include/dmlc/logging.h:235: [14:31:29] /home/zhangjl/git/mxnet/mshadow/mshadow/././././cuda/tensor_gpu-inl.cuh:351: Check failed: (dst.size(0)) == (label.size(0)) SoftmaxGrad: label shape mismatch
[14:31:29] /home/zhangjl/git/mxnet/dmlc-core/include/dmlc/logging.h:235: [14:31:29] src/engine/./threaded_engine.h:306: [14:31:29] /home/zhangjl/git/mxnet/mshadow/mshadow/././././cuda/tensor_gpu-inl.cuh:351: Check failed: (dst.size(0)) == (label.size(0)) SoftmaxGrad: label shape mismatch
An fatal error occurred in asynchronous engine operation. If you do not know what caused this error, you can try set environment variable MXNET_ENGINE_TYPE to NaiveEngine and run with debugger (i.e. gdb). This will force all operations to be synchronous and backtrace will give you the series of calls that lead to this error. Remember to set MXNET_ENGINE_TYPE back to empty after debugging.
terminate called after throwing an instance of 'dmlc::Error'
  what():  [14:31:29] src/engine/./threaded_engine.h:306: [14:31:29] /home/zhangjl/git/mxnet/mshadow/mshadow/././././cuda/tensor_gpu-inl.cuh:351: Check failed: (dst.size(0)) == (label.size(0)) SoftmaxGrad: label shape mismatch
An fatal error occurred in asynchronous engine operation. If you do not know what caused this error, you can try set environment variable MXNET_ENGINE_TYPE to NaiveEngine and run with debugger (i.e. gdb). This will force all operations to be synchronous and backtrace will give you the series of calls that lead to this error. Remember to set MXNET_ENGINE_TYPE back to empty after debugging.
Aborted (core dumped)

please show me how to set the ydim, thanks.

zhangjiulong avatar Aug 22 '16 06:08 zhangjiulong

@yzhang87 @pluskid

mli avatar Aug 23 '16 21:08 mli

@zhangjiulong seems like you need to change label size.

btw, you can change these parameters by passing "--train-xdim" into the python file.

yzhang87 avatar Aug 24 '16 18:08 yzhang87

@zhangjiulong Is this problems solved? I seem to encounter the same problem.

yaguanghu avatar Sep 18 '16 13:09 yaguanghu

i run the speech demo,but got the same error: ...cuda/tensor_gpu-inl.cuh:351: Check failed: (dst.size(0)) == (label.size(0)) SoftmaxGrad: label shape mismatch

wd929 avatar Oct 20 '16 10:10 wd929

@wd929 That was due to some incompatible changes in SoftmaxOutput lately. Could you try to add preserve_shape=True when constructing SoftmaxOutput to see if it works?

pluskid avatar Oct 20 '16 16:10 pluskid

@pluskid i try to add preserve_shape=true here

if take_softmax: sm = mx.sym.SoftmaxOutput(data=pred, label=label, ignore_label=0,use_ignore=True, name='softmax', preserve_shape=True) else: sm = pred

but it does`t work,the same error occured

wd929 avatar Oct 21 '16 03:10 wd929

@wd929 one temporary solution was reshape the label and pred.

pred = mx.sym.Reshape(pred, shape=(-1, num_label)) label = mx.sym.Reshape(label, shape=(-1,))

We will submit a fix soon (after we combined with cudnn-lstm).

yzhang87 avatar Oct 21 '16 04:10 yzhang87

@yzhang87 i reshape the label and pred but i got

src/operator/./reshape-inl.h:289: Check failed: oshape.Size() == dshape.Size() Target shape size is different to source. Target: 8315056683120

wd929 avatar Oct 21 '16 04:10 wd929

i try to add preserve_shape=true here

if take_softmax: sm = mx.sym.SoftmaxOutput(data=pred, label=label, ignore_label=0,use_ignore=True, name='softmax', preserve_shape=True) else: sm = pred

but it does`t work,the same error occured

2016-10-21 0:03 GMT+08:00 Chiyuan Zhang [email protected]:

@wd929 https://github.com/wd929 That was due to some incompatible changes in SoftmaxOutput lately. Could you try to add preserve_shape=True when constructing SoftmaxOutput to see if it works?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dmlc/mxnet/issues/3096#issuecomment-255150185, or mute the thread https://github.com/notifications/unsubscribe-auth/ATgiMkhlaFOxOEIHLiEK0kH7-iYaKqHwks5q15DmgaJpZM4JpjLD .

wd929 avatar Oct 25 '16 18:10 wd929

#3620 should fix this. We are planning to test cuDNN RNN cell for speech demo soon.

pluskid avatar Oct 25 '16 19:10 pluskid

@pluskid I pull the newest script.But I got another error. IndexError: index 1936 is out of bounds for axis 0 with size 1936 1936 is the label dim(i.e. $ of state) I think maybe I should -1 (0~1935) but i got the same error IndexError: index 1935 is out of bounds for axis 0 with size 1935 I don`t know why

wd929 avatar Oct 26 '16 06:10 wd929

The label dimension might be different from different kaldi run. @yzhang87 Maybe we should add comments on how to read out this parameter from kaldi outputs.

pluskid avatar Oct 26 '16 13:10 pluskid

@wd929 "index 1936 is out of bounds for axis 0 with size 1936", I think it means you need increase the your label dim. You can check final.occs in kaldi model file for the total number of labels.

yzhang87 avatar Oct 26 '16 14:10 yzhang87

@yzhang87 I checked the the number label is actually 1936 in final.occs and I checked label numbers in exp_mxnet/data-for-mxnet/label_mean.ark ,which is 1936 too.

wd929 avatar Oct 27 '16 03:10 wd929

Can you show me which line throw this error? By default, 0 is reserved for garbage frame, 1-label_dim was for the actual labels. Does it work if you increase the num_label in the config? It seems you feed-in some index which exceed the label_num.

yzhang87 avatar Oct 27 '16 03:10 yzhang87

@yzhang87 Traceback (most recent call last): File "train_lstm_proj.py", line 303, in do_training(training_method, args, module, data_train, data_val) File "train_lstm_proj.py", line 198, in do_training module.update_metric(eval_metric, data_batch.label) File "mxnet/python/mxnet/module/module.py", line 448, in update_metric self._exec_group.update_metric(eval_metric, labels) File "mxnet/python/mxnet/module/executor_group.py", line 312, in update_metric eval_metric.update(labels_slice, texec.outputs) File "mxnet/python/mxnet/metric.py", line 106, in update metric.update(labels, preds) File "mxnet/python/mxnet/metric.py", line 350, in update reval = self._feval(label, pred) File "mxnet/python/mxnet/metric.py", line 376, in feval return numpy_feval(label, pred) File "train_lstm_proj.py", line 67, in CrossEntropy loss += -np.log(max(1e-10, preds[i][int(label)])) IndexError: index 1936 is out of bounds for axis 0 with size 1936

And i increase the number of label to 1937,it seems to work...there is no error till now.

wd929 avatar Oct 27 '16 04:10 wd929

For this error, it seems due to the label index is from 1, not from 0. In train_lstm_proj.py for function def CrossEntropy(labels, preds): in the loop for i in range(preds.shape[0]), you can just let label:=label-1

nichongjia avatar Nov 13 '16 05:11 nichongjia

This issue is closed due to lack of activity in the last 90 days. Feel free to reopen if this is still an active issue. Thanks!

yajiedesign avatar Sep 28 '17 07:09 yajiedesign