2017-04-08 20 views
0

私は音声シーケンス認識のためにctc損失のblstmをトレーニングしようとしています。トレーニング中にケラスエラーのあるctc blstm

def ctc_lambda_func(args): 
    y_pred, labels, input_length, label_length = args 
    # the 2 is critical here since the first couple outputs of the RNN 
    # tend to be garbage: 
    y_pred = y_pred[:, 2:, :] 

    ctc_batch_loss = K.ctc_batch_cost(labels, y_pred, input_length, label_length) 

    return ctc_batch_loss 

私は信じている:

W tensorflow/core/framework/op_kernel.cc:993] Invalid argument: slice index 0 of dimension 0 out of bounds. 
    [[Node: ctc/scan/strided_slice = StridedSlice[Index=DT_INT32, T=DT_INT32, begin_mask=0, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=1, _device="/job:localhost/replica:0/task:0/gpu:0"](ctc/scan/Shape, ctc/scan/strided_slice/stack, ctc/scan/strided_slice/stack_1, ctc/scan/strided_slice/stack_2)]] 
Traceback (most recent call last): 
    File "speech_lstm_ctc.py", line 212, in <module> 
    callbacks=[earlystopping, checkpoint, data_gen]) 
    File "/usr/local/lib/python2.7/dist-packages/keras/legacy/interfaces.py", line 88, in wrapper 
    return func(*args, **kwargs) 
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1876, in fit_generator 
    class_weight=class_weight) 
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/training.py", line 1620, in train_on_batch 
    outputs = self.train_function(ins) 
    File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 2073, in __call__ 
    feed_dict=feed_dict) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 767, in run 
    run_metadata_ptr) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 965, in _run 
    feed_dict_string, options, run_metadata) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1015, in _do_run 
    target_list, options, run_metadata) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1035, in _do_call 
    raise type(e)(node_def, op, message) 
tensorflow.python.framework.errors_impl.InvalidArgumentError: slice index 0 of dimension 0 out of bounds. 
    [[Node: ctc/scan/strided_slice = StridedSlice[Index=DT_INT32, T=DT_INT32, begin_mask=0, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=1, _device="/job:localhost/replica:0/task:0/gpu:0"](ctc/scan/Shape, ctc/scan/strided_slice/stack, ctc/scan/strided_slice/stack_1, ctc/scan/strided_slice/stack_2)]] 
    [[Node: ctc/scan/while/Less_1/_77 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_981_ctc/scan/while/Less_1", tensor_type=DT_BOOL, _device="/job:localhost/replica:0/task:0/cpu:0"](^_cloopctc/scan/while/TensorArrayReadV3/_17)]] 

Caused by op u'ctc/scan/strided_slice', defined at: 
    File "speech_lstm_ctc.py", line 189, in <module> 
    loss_out = Lambda(ctc_lambda_func, output_shape=(1,), name="ctc")([y_pred, labels, input_length, label_length]) 
    File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 554, in __call__ 
    output = self.call(inputs, **kwargs) 
    File "/usr/local/lib/python2.7/dist-packages/keras/layers/core.py", line 659, in call 
    return self.function(inputs, **arguments) 
    File "speech_lstm_ctc.py", line 141, in ctc_lambda_func 
    ctc_batch_loss = K.ctc_batch_cost(labels, y_pred, input_length, label_length) 
    File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 3258, in ctc_batch_cost 
    sparse_labels = tf.to_int32(ctc_label_dense_to_sparse(y_true, label_length)) 
    File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 3222, in ctc_label_dense_to_sparse 
    initializer=init, parallel_iterations=1) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/functional_ops.py", line 524, in scan 
    n = array_ops.shape(elems_flat[0])[0] 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 495, in _SliceHelper 
    name=name) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 653, in strided_slice 
    shrink_axis_mask=shrink_axis_mask) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3688, in strided_slice 
    shrink_axis_mask=shrink_axis_mask, name=name) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op 
    op_def=op_def) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2327, in create_op 
    original_op=self._default_original_op, op_def=op_def) 
    File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1226, in __init__ 
    self._traceback = _extract_stack() 

InvalidArgumentError (see above for traceback): slice index 0 of dimension 0 out of bounds. 
    [[Node: ctc/scan/strided_slice = StridedSlice[Index=DT_INT32, T=DT_INT32, begin_mask=0, ellipsis_mask=0, end_mask=0, new_axis_mask=0, shrink_axis_mask=1, _device="/job:localhost/replica:0/task:0/gpu:0"](ctc/scan/Shape, ctc/scan/strided_slice/stack, ctc/scan/strided_slice/stack_1, ctc/scan/strided_slice/stack_2)]] 
    [[Node: ctc/scan/while/Less_1/_77 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_981_ctc/scan/while/Less_1", tensor_type=DT_BOOL, _device="/job:localhost/replica:0/task:0/cpu:0"](^_cloopctc/scan/while/TensorArrayReadV3/_17)]] 

CTC損失を実装する機能は以下の通りです:私は、実行中のコードを得ることができたが、訓練は次のエラーを有する第二エポックの特定の段階で失敗します異なる入力であっても同じステップで毎回表示されるため、エラーは特定の入力と関係しないことに注意してください。

何が原因である可能性がありますか?

答えて

0

問題を引き起こしたのは、実際にバッチジェネレータがある時点でサイズ1のミニバッチを与え、テンソルフローがクラッシュしたようです。ミニバッチを常に1より大きくすることで修正しました。

関連する問題