Skip to content

Instantly share code, notes, and snippets.

@chrisdinant
Created March 14, 2018 09:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdinant/20f48750026fa88a90475ed8a3001850 to your computer and use it in GitHub Desktop.
Save chrisdinant/20f48750026fa88a90475ed8a3001850 to your computer and use it in GitHub Desktop.
y_pred = TimeDistributed(Dense(output_dim, activation = 'softmax'))(X)
# ctc
y_true = Input(name='the_labels', shape=[None,], dtype='int32')
input_length = Input(name='input_length', shape=[1], dtype='int32')
label_length = Input(name='label_length', shape=[1], dtype='int32')
# Keras doesn't currently support loss funcs with extra parameters
# so CTC loss is implemented in a lambda layer
loss_out = Lambda(ctc_lambda_func, output_shape=(1,),
name='ctc')([y_pred,
y_true,
input_length,
label_length])
test_model = Model(inputs = X_input, outputs = y_pred)
model = Model(inputs = [X_input,
y_true,
input_length,
label_length],
outputs = loss_out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment