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

Speed Issues #16

Open
ekinakyurek opened this issue Dec 22, 2020 · 1 comment
Open

Speed Issues #16

ekinakyurek opened this issue Dec 22, 2020 · 1 comment

Comments

@ekinakyurek
Copy link
Contributor

ekinakyurek commented Dec 22, 2020

1. CuDNN-RNN sorting requirement:

To call CuDNN, we need to sort sequences by length. This breaks the order of sentence, so we need to reorder hidden states after the call. This might be a slow procedure, we might come up with an alternative. Any ideas @denizyuret ? I guess we can do padding from right to make sequences same length, and process them at once. And make the embeddings of pads 0, and expect RNN to learn to ignore those 0s.

return out.hidden[:,:,end][:,indices], out.memory[:,:,end][:,indices]

2. Minibatching at decoding time:

1- We can't process all words at once because of the output encoding. Should we stick to non output-encoding version of the model for faster public model? @denizyuret

2- I believe we should be able to eliminate for loop over the characters of a word (for t=1:timeSteps). Is there any obstacle for that? I guess this is only helpful in training

Morse.jl/src/models.jl

Lines 284 to 306 in 2dfe277

for w=1:wordNumber
dh2 = (hiddens2[1][:,w:w] .+ hiddens3[1], hiddens2[2][:,w:w] .+ hiddens3[2])
dh1 = (hiddens1[1][:,w:w], hiddens1[2][:,w:w])
input = v.specialIndices.bow
outEmbedding = [];
continueStoring = true
for t=1:timeSteps
rnninput = M.outputEmbed([input])
if continueStoring && input == v.specialIndices.eow
continueStoring = false
elseif continueStoring && input v.specialIndices && length(v.tags[input]) > 1
push!(outEmbedding,rnninput)
end
dh1, dh2 = M.decoder(rnninput, dh1, dh2; training=false)
h2 = dh2[1]
scores = M.output(reshape(h2, size(h2,1), size(h2,2)))
#prediction
input = argmax(convert(Array,scores))[1]
preds[w,t] = input
# loss calculation
total += M.loss(scores, d.seqOutputs[w:w,t] .* d.masks[w:w,t]; average=false)

@denizyuret
Copy link
Member

denizyuret commented Dec 23, 2020 via email

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

2 participants