The only option with Theano would be to write your own op that would run in parallel on the GPU.
This is not an easy task. > Le 10 déc. 2018 à 07:35, Wong Hang <wongh...@gmail.com> a écrit : > > Hi, > > I am working on a problem that is similar to this one: > > import theano > import theano.tensor as T > import theano.tensor.slinalg as Tla > cholesky=Tla.cholesky > solve_lower_triangular=Tla.solve_lower_triangular > import numpy as np > > > def _LL(k,ret,data,mu,sigma): > jitter = 1e-6*T.eye(3) > L = cholesky(sigma + jitter) > err = data[k] - mu > Lerr = solve_lower_triangular(L,err) > > > LL = -0.5*1.83787706640934533908e+00 > LL -= T.sum(T.log(T.diag(L))) > LL -= 0.5*T.sum(T.sqr(Lerr)) > return ret + LL > > > def compile(N): > sigma = np.array([ > [1.0,0.5,-0.3], > [0.5,2.0,0.], > [-0.3,0.,1.5], > ],dtype=np.float64) > > > mu = np.array([ > -2.0, > 1.0, > -4.0, > ],dtype=np.float64) > > > data = > np.random.multivariate_normal(mu,sigma,size=(N,),check_valid='raise') > data = theano.shared(data) > > > mu = theano.shared(np.zeros((3,))) > sigma = theano.shared(np.eye((3))) > > > result,updates = theano.scan(fn=_LL, > outputs_info=np.float64(0.), > sequences=np.arange(N), > non_sequences=[data,mu,sigma]) > params = [mu,sigma] > g = T.grad(-result[-1],params) > f = theano.function(inputs=[], > outputs=g, > updates=updates) > > > return f > > > if __name__ == "__main__": > np.random.seed(12345) > N = 100 > > score = compile(N) > print(score()) > > > But the difference is, each data block is of different dimensional > multivariate normal distribution and the mean / covariance is further > parameterized by something else (but same for each data block) > > I did some research and acknowledged theano.scan run sequentially. > > Are there any other way to write the same code to run in parallel on GPU? > > Thanks. > > > > > -- > > --- > 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+unsubscr...@googlegroups.com > <mailto:theano-users+unsubscr...@googlegroups.com>. > For more options, visit https://groups.google.com/d/optout > <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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.