Merge pull request #428 from tejank10/rnn-fixes

[WIP] Fixes for RNN tests
This commit is contained in:
Mike J Innes 2018-10-10 16:58:44 +01:00 committed by GitHub
commit ab0763fd41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -46,10 +46,10 @@ const RNN_ALGO_PERSIST_DYNAMIC = 2
# LSTM: [weight, bias] × [input, hidden] × [input, forget, newmem, output]
function params(w::CuVector, input, hidden, n = 1)
slice(offset, shape) = reshape(w[offset.+(1:prod(shape))], shape)
slice(offset, shape) = reshape(view(w, offset.+(1:prod(shape))), shape)
wx = slice(0, (input, hidden*n))
wh = slice(length(wx), (hidden, hidden*n))
bias = w[length(wx)+length(wh) .+ (1:hidden*n)]
bias = view(w, length(wx)+length(wh) .+ (1:hidden*n))
(wx, wh), bias
end