-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use CTC loss function? #68
Comments
You can use ctc_layer and ctc_error_evaluator as follows. Note, in consideration of the ‘blank’ label is needed by CTC, the size of ctc_layer and its input layer should be 134 (133 + 1). The 'blank' is the last category index by default, namely 133. We also integrate warp-CTC before, which may be merged later.
|
@qingqing01 Many thanks. |
@F0REacH I forget to remind you to update the code. |
@qingqing01 I saw commit 9f3cbed fixed ctc issues. Nice work |
Hi, @qingqing01 def stacked_gru_net_with_ctc(input_dim=24,
class_dim=133,
hid_dim=129,
stacked_num=3,
is_predict=False):
"""
"""
assert stacked_num % 2 == 1
linear = LinearActivation()
data = data_layer("word", input_dim)
fc1 = fc_layer(input=data, size=hid_dim, act=linear)
gru1 = grumemory(input=fc1)
inputs = [fc1, gru1]
for i in range(2, stacked_num + 1):
fc = fc_layer(input=inputs, size=hid_dim, act=linear)
gru = grumemory(input=fc, reverse=(i % 2) == 0)
inputs = [fc, gru]
output = fc_layer(input=inputs, size=class_dim+1, act=SoftmaxActivation())
label = data_layer('label', class_dim)
ctc = ctc_layer(input=output, label=label, size=class_dim+1)
if is_predict:
outputs(output)
else:
eval = ctc_error_evaluator(input=output, label=label)
outputs(ctc) But somehow started getting segmentation fault error:
|
Hi, please refer to the changes in |
Thanks, @qingqing01 with pull #82 all is OK. |
Fix seq2seq and transformer on cpu
support compute_at in PolyScheduler
* add equal,mean, fix mul * add equal, mean, elementwis_miul tests * include header
* Update Dureader-yesno example, fix run_glue bug * minor fix * minor fix * add predict() func * minor fix * add paddle.no_grad() for eval
Add FAQ for Paddle Inference.
* update demo
…d enable train binding cpu mode support mix train (#68)
Co-authored-by: zhongweics <zhongweics@gmail.com>
propagate nan and inf in relu and scaled_fc
refactor ShardableAxesSignature by group_pattern.SoleOutputShardableAxes
How to use CTC loss function?
I'm planning to extend my dataset with unsegmented data, but cannot figure out how to use ctc_error_evaluator and ctc_layer
model:
dataprovider:
Also I have no idea how to feed labels to model if sequences are not segmented. With simple classification_cost each timestep has label, but how to use dataprovider with unsegmented sequences and CTC?
My current dataset is 180 examples, each is roughly 5000 timesteps (variable length). Each timestep is len=24 float vector labeled with one int label in range 0..132 (133 labels total).
Any example/suggestion would be highly appreciated. Thanks
The text was updated successfully, but these errors were encountered: