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…
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…
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.…
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…
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)…
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))
…
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…
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…
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…
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…
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…
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…
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),…
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 =…