Questions tagged [theano.scan]

Allows for looping in theano python library

Allows for looping in theano python library

36 questions
10
votes
0 answers

Nonlinear convolution in Theano

I'm trying to make a "custom" convolutional layer in Theano, where instead of linear filters convoluted with an image, I'm applying sup- or inf- convolutions (essentially dilations and erosions). How would I go in writing such a convolution in an…
VHarisop
  • 2,816
  • 1
  • 14
  • 28
3
votes
1 answer

efficient kernel implementation in theano

I have just implemented a Gaussian kernel in Theano. However when I tested it as part of a neural network, it takes too long. It seems that the kernel subtractions are not paralellized. The whole training of the network uses a single processing…
Nacho
  • 792
  • 1
  • 5
  • 23
3
votes
0 answers

Using theano.scan in pymc3 models

I'm trying to infer parameters of a stochastic dynamical system using pymc3. I have a theano expression that seems to come together without errors, but I can't seem to compile it, which I was hoping to do in order to generate toy data for fitting.…
Noah
  • 196
  • 10
2
votes
0 answers

ValueError when applying theano's scan function

I'm trying to evaluate a multivariate normal CDF several times using theano's scan function, but I'm getting a ValueError. Here's an example of the original function I'm trying to vectorize: from scipy.stats.mvn import mvnun # library that…
Felipe D.
  • 1,157
  • 9
  • 19
2
votes
1 answer

3D Matrix multiplication in numpy and theano

I have a matrix A with size (5,7,3) and a matrix B with size (5,3,8). I want to multiply them C = A.B, and the size of C is (5,7,8). It means that one 2D submatrix with size (7,3) in matrix A will be multiplied with one 2D submatrix with size (3,8)…
2
votes
1 answer

How to iterate over the rows of a theano matrix using the scan function in theano?

I am writing a simple code to compute one-hot encoding for a list of indices. Eg: [1,2,3] => [[0,1,0,0],[0,0,1,0],[0,0,0,1]] I write a function to do the same for a single vector: n_val =4 def encoding(x_t): z = T.zeros((x_t.shape[0], n_val)) …
2
votes
1 answer

Theano : Pass iterating index of scan to the called function

Is it possible to pass the iterating index of scan to the function I am calling from scan? For eg - def step(x,i): # i is the current scan index. Use it for some conditional expressions for i in range(0,10): step(x,i) I want to do something…
dragster
  • 448
  • 1
  • 4
  • 20
1
vote
1 answer

Can not use cuDNN on context None: cannot compile with cuDNN: fatal error: cudnn.h: No such file or directory

I configured theano to be connected to the GPU and I installed all the required libraries. I used the following code from the documentation to check if the GPU work: THEANO_FLAGS='floatX=float32,device=cuda0,gpuarray.preallocate=1' python…
Minions
  • 5,104
  • 5
  • 50
  • 91
1
vote
1 answer

Weighted matrix given weight-vector with scan (theano)

I'm new to theano and still wrapping my head around scan. I want to compute a weighted matrix from row-weights, weight that by the weight's probability and get the corresponding weighted matrix. However, I'm having trouble iterating over weights in…
Brox
  • 117
  • 6
1
vote
2 answers

how to use scan to compute Dot-product of two vectors in theano

Let's say, one vector is [1, 2, 3, 4] and the other one is [1, 2, 3, 4], so the result should be [1, 4, 9, 16]. if I want to write the dot product of these two vectors in theano, how can I achieve this using Scan ? This is my code , however, the…
tqjustc
  • 3,624
  • 6
  • 27
  • 42
1
vote
0 answers

Variable Taps in Theano Scan

I'm trying to implement a theano version of conjugated gradients for Hessian-Free optimisation as described in this paper: http://icml2010.haifa.il.ibm.com/papers/458.pdf. The termination condition used for the conjugate gradient algo is that the…
R.Habib
  • 29
  • 5
1
vote
1 answer

How to apply scalar multiplication using elements of one tensor along the elements of another tensor?

Given two tensors, A (m x n x q) and B (m x n x 1), how do you create a function which loops through rows of A, treating each element of B (n x 1) as a scalar and applying them to the vectors (q x 1) of the sub-matrices of A (n x q)? e.g., A is…
Andy
  • 175
  • 1
  • 7
1
vote
1 answer

How does theano's scan function work?

Look at this code: import theano import numpy import theano.tensor as T import numpy as np x = T.dvector('x') y = T.dvector('y') def fun(x,a): return x+a results, updates = theano.scan(fn=fun,sequences=dict(input=x),…
Gauss
  • 379
  • 5
  • 18
1
vote
0 answers

using Theano.scan for iterating over ndarray with a condition

Pardon me for a basic question(I am new to Theano)! I want to get the difference of 2 matrices for only those positions that satisfy a condition. So, suppose we have 2 matrices A and B, this(python equivalent code) is what I want to calculate: sum =…
1
vote
0 answers

theano less than function gives wrong answer

Here is a code snippet : seqLen = 4 seq = np.repeat([seqLen-1],seqLen) print seq def step2(idx): if T.lt(idx,seqLen-1): return T.constant(True) else: return T.constant(False) # return T.lt(idx,seqLen-1) …
dragster
  • 448
  • 1
  • 4
  • 20
1
2 3