CTC 训练的调试bug记录

1.  InvalidArgumentError: Not enough time for target transition sequence (required: 21, available: 15)70You can turn this error into a warning by using the flag ignore_longer_outputs_than_inputs

原因:输入数据的标签长度大于数据序列的长度,即seq_len大于了time_step. 

解决办法:1)确保数据的前处理后label长度小于序列长度,通常发生在对数据做特征提取后长度变短小于label长度;

                  2)设置ignore_longer_outputs_than_inputs为True,此时遇到这类训练数据,CTCLoss会自动返回0梯度;

                        tf.nn.ctc_loss(targets, logits, seq_len,ignore_longer_outputs_than_inputs=True)

 The `ignore_longer_outputs_than_inputs` option allows to specify the behavior
  of the CTCLoss when dealing with sequences that have longer outputs than
  inputs. If true, the CTCLoss will simply return zero gradient for those
  items, otherwise an InvalidArgument error is returned, stopping training.

 

2. InvalidArgumentError: sequence_length(1) <= 132

原因:ctcloss计算要求所有sequence_length要小于max_time_step,通常max_time_step等于CTCLoss的输入序列数据的最大长度,即下面input_shape.dim_size(0),报错的是因为存在sequence_length大于了max_time_step。

解决办法:检查CTCLoss的输入数据和sequence_length是否对应,通常由于数据先进入了CNN导致输入到CTC的数据维度发生了变化,而sequence_length还对应CNN前的数据序列长度,故按照CNN结构缩放你的原始sequence_length即可。

inputs: 3-D `float` `Tensor`.
      If time_major == False, this will be a `Tensor` shaped:
        `[batch_size, max_time, num_classes]`.
      If time_major == True (default), this will be a `Tensor` shaped:
        `[max_time, batch_size, num_classes]`.
      The logits.

# From ctc_loss_op.cc
    for (int64 b = 0; b < batch_size; ++b) {
      OP_REQUIRES(
          ctx, seq_len_t(b) <= max_time,
          errors::InvalidArgument("sequence_length(", b, ") <= ", max_time));
    }

 

  • 6
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值