Skip to content
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

wrong loss returned by ctc_cost() #15

Open
david-leon opened this issue Jan 18, 2017 · 0 comments
Open

wrong loss returned by ctc_cost() #15

david-leon opened this issue Jan 18, 2017 · 0 comments

Comments

@david-leon
Copy link

@mcf06 I compared the returned average loss by ctc_cost() and my own theano-based version, and the results are never consistent. The following are the result examples, loss1 is the result of my own theano version, and loss2 is the result from ctc_cost()

loss1 = 33.0587, loss2 = 32.9557
loss1 = 30.6853, loss2 = 32.0488
loss1 = 31.6061, loss2 = 33.2019
loss1 = 31.8931, loss2 = 31.1848
loss1 = 31.2144, loss2 = 31.2196
loss1 = 33.4684, loss2 = 35.6380
loss1 = 29.9425, loss2 = 32.2495
loss1 = 30.3169, loss2 = 32.5860
loss1 = 30.8735, loss2 = 31.2624
loss1 = 32.9855, loss2 = 32.8420

The way I use ctc_cost() is as

import theano.tensor as tensor
sm_tensor  = tensor.ftensor3()    # activation output, before softmax
seq_tensor_i = tensor.imatrix()   # target label sequence
loss_tensor2 = ctc_cost(sm_tensor.dimshuffle(1, 0, 2), seq_tensor_i)
f2 = theano.function([seq_tensor_i, sm_tensor], loss_tensor2)

B = 1                  # batch size
T = 20                 # time steps
Np1 = 11               # class number plus 1
L = 8                  # label length
x = np.random.rand(B, T, Np1).astype('float32')
y = np.random.randint(0, Np1-1, size=(B, L)) + 1
loss2 = np.mean(f2(y.astype('int32'), x))

Is there any place I've done wrongly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant