Discussion:
[theano-users] theano mean for certain indices in a vector
Shadekur Rahman
2017-09-04 07:36:03 UTC
Permalink
I am quite new in theano. I am having problem to implement the following:

import theano.tensor as T
A = T.vector('A')
B = T.vector('B') #represents list of indices of A
C = T.scalar('C') #represents mean of A for certain indices stored in B
D = T.vector('D')
E = T.vector('E')
# E should be concatenation of C and D with length (D.length+1)
func = theano.function(inputs=[A,B,D],outputs=E)

Can anyone give me idea how to calculate C and E?
--
---
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 theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Frédéric Bastien
2017-09-08 14:15:13 UTC
Permalink
You must make your indices interger like `B = T.ivector('B')`.

With that, you can do indexing to select just the values you want:

A[B]

Thean compute the mean on them:

C = A[B].mean()

If E should be a vector, you can concatenate C and D like this:

theano.tensor.concatenate([C, D])

Frédéric
Post by Shadekur Rahman
import theano.tensor as T
A = T.vector('A')
B = T.vector('B') #represents list of indices of A
C = T.scalar('C') #represents mean of A for certain indices stored in B
D = T.vector('D')
E = T.vector('E')
# E should be concatenation of C and D with length (D.length+1)
func = theano.function(inputs=[A,B,D],outputs=E)
Can anyone give me idea how to calculate C and E?
--
---
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
For more options, visit https://groups.google.com/d/optout.
--
---
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 theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...