Hi all,

I tried to get the gradients from Theano in numpy type. But, when I defined 
the function, it returned pygpu.gpuarray.GpuArray. How can I solve this 
problem?

Here is my function:
----------------------------------------------------------------------------------------------------------------------------
cost  = classifier.negative_log_likelihood(answer, answer_mask)
grads = T.grad(cost, list(classifier.tparams.values()))

optim = optimizer()
# updates = optim(itemlist(classifier.tparams), grads)

train_model = theano.function(
inputs=[],
outputs=[cost] + grads,
# updates=updates,
givens={
img: shared_img, ques: shared_ques_casted, ans: shared_ans_casted[:-1],
m_ques: shared_m_ques, m_ans: shared_m_ans[:-1],
answer: shared_ans_casted[1:], answer_mask: shared_m_ans[1:]
}
)

test_model = theano.function(
inputs=[],
outputs=classifier.samples(length_answer-1),
givens={
img: shared_img, ques: shared_ques_casted,
m_ques: shared_m_ques
}
)
------------------------------------------------------------------------------------------------------------------------------

Here is the type of the returned gradients (the first one is in numpy type 
but the other are not):

<type 'numpy.ndarray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>
<type 'pygpu.gpuarray.GpuArray'>

Thank you in advance

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to