本文整理汇总了Python中keras.backend.ctc_batch_cost方法的典型用法代码示例。如果您正苦于以下问题:Python backend.ctc_batch_cost方法的具体用法?Python backend.ctc_batch_cost怎么用?Python backend.ctc_batch_cost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keras.backend
的用法示例。
在下文中一共展示了backend.ctc_batch_cost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ctc_lambda_func
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
def ctc_lambda_func(args):
y_pred, labels, input_length, label_length = args
# hack for load_model
import tensorflow as tf
''' from TF: Input requirements
1. sequence_length(b) <= time for all b
2. max(labels.indices(labels.indices[:, 1] == b, 2)) <= sequence_length(b) for all b.
'''
# print("CTC lambda inputs / shape")
# print("y_pred:",y_pred.shape) # (?, 778, 30)
# print("labels:",labels.shape) # (?, 80)
# print("input_length:",input_length.shape) # (?, 1)
# print("label_length:",label_length.shape) # (?, 1)
return K.ctc_batch_cost(labels, y_pred, input_length, label_length)
示例2: ctc_lambda_func
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
def ctc_lambda_func(args):
y_pred,labels,input_length,label_length = args
return K.ctc_batch_cost(labels, y_pred, input_length, label_length)
示例3: _ctc_loss
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
def _ctc_loss(args):
labels, y_pred, input_length, label_length = args
return K.ctc_batch_cost(labels, y_pred, input_length, label_length)
示例4: ctc_lambda_func
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
def ctc_lambda_func(args):
y_pred, labels, input_length, label_length = args
return K.ctc_batch_cost(labels, y_pred, input_length, label_length)
#
# Get Model
#
开发者ID:Orkis-Research,项目名称:Quaternion-Convolutional-Neural-Networks-for-End-to-End-Automatic-Speech-Recognition,代码行数:9,代码来源:interspeech_model.py
示例5: ctc_lambda_func
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
def ctc_lambda_func(args):
y_pred, labels, input_length, label_length = args
y_pred = y_pred[:, 2:, :]
return K.ctc_batch_cost(labels, y_pred, input_length, label_length)
示例6: ctc_lambda_func
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
def ctc_lambda_func(args):
iy_pred, ilabels, iinput_length, ilabel_length = args
# the 2 is critical here since the first couple outputs of the RNN
# tend to be garbage:
iy_pred = iy_pred[:, 2:, :] # no such influence
return K.ctc_batch_cost(ilabels, iy_pred, iinput_length, ilabel_length)
示例7: ctc_lambda_func
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
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:, :]
return K.ctc_batch_cost(labels, y_pred, input_length, label_length)
示例8: ctc_lambda_func
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
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:, :]
return K.ctc_batch_cost(labels, y_pred, input_length, label_length)
# For a real OCR application, this should be beam search with a dictionary
# and language model. For this example, best path is sufficient.
示例9: ctc_lambda_func
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
def ctc_lambda_func(args):
y_pred, labels, input_length, label_length = args
# From Keras example image_ocr.py:
# the 2 is critical here since the first couple outputs of the RNN
# tend to be garbage:
# y_pred = y_pred[:, 2:, :]
y_pred = y_pred[:, :, :]
return K.ctc_batch_cost(labels, y_pred, input_length, label_length)
示例10: ctc_lambda_func
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
def ctc_lambda_func(self, args):
y_pred, labels, input_length, label_length = args
y_pred = y_pred[:, :, :]
return K.ctc_batch_cost(y_true=labels, y_pred=y_pred, input_length=input_length, label_length=label_length)
示例11: _ctc_lambda
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
def _ctc_lambda(args):
prediction_batch, label_batch, prediction_lengths, label_lengths = args
return backend.ctc_batch_cost(y_true=label_batch, y_pred=prediction_batch,
input_length=prediction_lengths, label_length=label_lengths)
示例12: ctc_lambda_func
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
def ctc_lambda_func(args):
y_pred, labels, input_length, label_length = args
return K.ctc_batch_cost(labels, y_pred, input_length, label_length)
示例13: ctc_loss_lambda_func
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
def ctc_loss_lambda_func(args):
"""
Function for computing the ctc loss (can be put in a Lambda layer)
:param args:
y_pred, labels, input_length, label_length
:return: CTC loss
"""
y_pred, labels, input_length, label_length = args
return K.ctc_batch_cost(labels, y_pred, input_length, label_length) # , ignore_longer_outputs_than_inputs=True)
示例14: ctc_lambda_func
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
def ctc_lambda_func( args ):
prediction, labels, prediction_lengths, label_lengths = args
# prediction = prediction[:, 2:, :]
return K.ctc_batch_cost( labels, K.softmax( prediction ), prediction_lengths, label_lengths )
示例15: ctc_lambda_func
# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import ctc_batch_cost [as 别名]
def ctc_lambda_func( args ):
y_pred, labels, label_lengths = args
y_pred_len = [ [y_pred.shape[1] ] ] * batchSize
# y_pred = y_pred[:, 2:, :]
return K.ctc_batch_cost( labels, K.softmax( y_pred ), y_pred_len, label_lengths )