Questions tagged [theano.scan]

Allows for looping in theano python library

Allows for looping in theano python library

36 questions
1
vote
1 answer

Theano Using `scan` Instead Of `for` Loop In Linear Regression

I'm trying to get a better grasp of the scan functionality in theano, my understanding is that it behaves like a for loop based on this document. I've created a very simple working example to find the weight and bias when performing linear…
Lukasz
  • 2,476
  • 10
  • 41
  • 51
1
vote
1 answer

How to add each element in two vectors with Theano?

I would like to know how to add each element in two vectors with Theano? Assume that we have two vector vector_1 and vecotr_2, and we would like to construct a matrix A, where A[i][j] = vector_1[i] + vecotr_2[j] I know that in numpy we can use…
z.Lam
  • 11
  • 3
1
vote
1 answer

What arguments does "sequences" paramater take in theano.scan and how are they interpreted

I have taken the following code from http://deeplearning.net/software/theano/library/scan.html import numpy coefficients = theano.tensor.vector("coefficients") x = T.scalar("x") max_coefficients_supported = 10000 # Generate…
Heisenbug
  • 126
  • 6
1
vote
0 answers

How to use propertly theano.scan in the SGD updates of a simple Probabilistic Matrix Factorization algorithm?

I am trying to implement Probabilistic Matrix Factorization with Stochastic Gradient Descent updates, in theano, without using a for loop. I have just started learning the basics of theano; unfortunately on my experiment I get this…
fstab
  • 4,801
  • 8
  • 34
  • 66
1
vote
1 answer

Strange behavior of scan in Theano when outputs has last dimension equal to one

I have a strange error that I don't manage to understand when compiling a scan operator in Theano. When outputs_info is initialized with a last dimension equal to one, I get this error: TypeError: ('The following error happened while compiling the…
1
vote
0 answers

Theano Tutorial Computing the Jacobian with Scan

In the Theano Tutorial: http://deeplearning.net/software/theano/tutorial/gradients.html or >>> import theano >>> import theano.tensor as T >>> x = T.dvector('x') >>> y = x ** 2 >>> J, updates = theano.scan(lambda i, y,x : T.grad(y[i], x),…
Max
  • 71
  • 1
  • 1
  • 6
1
vote
2 answers

TypeError: Inconsistency in the inner graph of scan 'scan_fn' .... 'TensorType(float64, col)' and 'TensorType(float64, matrix)'

I'm getting the following error when I try to run my LSTM program (for variable length inputs). TypeError: Inconsistency in the inner graph of scan 'scan_fn' : an input and an output are associated with the same recurrent state and should…
inblueswithu
  • 953
  • 2
  • 18
  • 29
0
votes
0 answers

Jacobian of theano scan creates named copies of symbolic variables, resulting in wrongly assigned inputs and UnusedInputError

I have a model in which rates of a random (Poisson) process are distributed according to a function p_nu(gamma,delta,nu_max). With pymc3/theano I want to obtain the posterior distribution of gamma,delta,nu_max when observing N_AP events (N_AP being…
wollex
  • 3
  • 3
0
votes
1 answer

Translating python loop to Theano

I want to transform a P vector of n elements into a Z vector of n+1 elements using the following formula: I was able to do that in python with: import numpy as np def p_to_Z(p): k = len(p) Z = np.zeros(k+1) Z[0] = p[0] Z[1:k] =…
user2597079
  • 37
  • 1
  • 7
0
votes
1 answer

Using theano.scan within PyMC3 gives TypeError: slice indices must be integers or None or have an __index__ method

I would like to to use theano.scan within pymc3. I run into problems when I add more than two variables as sequences. Here is a simple example: import numpy as np import pymc3 as pm import theano import theano.tensor as T a = np.ones(5) b =…
Maria
  • 108
  • 1
  • 6
0
votes
0 answers

theano dot product between a matrix and 3D tensor

I have a matrix and 3D tensor defined as below : import numpy as np import theano import theano.tensor as T a = T.matrix('a', dtype='float32') c = T.tensor3('c',dtype='float32') d = T.batched_dot(c, a) g = theano.function([a,c],d) Y = [[[1, 0, 0,…
Shyamkkhadka
  • 1,438
  • 4
  • 19
  • 29
0
votes
1 answer

some error happened when I run the example code in the theano scan api guide

Win 10 x64, conda, theano 0.9, python 3.6.1, spyder 3.1.4, IPython 6.0.0 When I test the code in scan api tutorial Iterating over the first dimension of a tensor: Calculating a polynomial , i.e. import theano import numpy as np import theano.tensor…
sejabs
  • 43
  • 5
0
votes
1 answer

TypeError when accessing RNN results

I am trying to extract the decisions of an RNN for all tokens in a sequence but receive the error mentioned at the end of the post. Any help will be appreciated! Code: # gated recurrent unit def gru_step(x, h_prev, W_xm, W_hm, W_xh, W_hh): m =…
ginge
  • 1,962
  • 16
  • 23
0
votes
1 answer

indexing a list with a tensor scalar variable in theano

I have a list : my_list = [[1,2,3,4], [4,5,6], [1,2,1,2,1,2]] I also have a tensor variable: a_tensor = theano.tensor.ivector("tensor") now I want to use theano.scan to get the corresponding item in the list given the index: result, _ =…
Hungry fool
  • 27
  • 1
  • 6
0
votes
2 answers

Why I am wrong to concatenate matrix and vector?

This is my code in theano max_max=200 beReplaced=T.matrix() toReplace=T.matrix() timeArray=T.arange(max_max) def f(v,k,w): return T.concatenate([w[:k],v,w[k+1:]],axis=0) result,_=theano.scan(f, …
Nick Qian
  • 129
  • 2
  • 9