Hello everyone 

I have been trying to do a 1d convolution in theano for problem i am doing 
in Pymc3, which is built on top of theano.

I have used the theano.tensor.signal.conv.conv2d function to do the 
convolution between the data and the function i have, but from what i 
understand from the docs 
<http://deeplearning.net/software/theano/library/tensor/signal/conv.html?highlight=border_mode#theano.tensor.signal.conv.conv2d>
 and 
this conversation <https://github.com/Theano/Theano/issues/2118> that there 
is no border_mode='same' in theano like with numpy and scipy, which makes 
the output dimensions the same as the input.

My idea was to make a function which could take the output of the 
border_mode='full' convolution and take the middle of the array and take 
half the length of the data array in each direction from the middle of the 
output and create a new array. This new array i could then in the sampler. 
i came up with the following that takes into account even and odd array 
sizes: 

*def findMiddle(input_list):*
*    if len(input_list) % 2 != 0:*
*        return (int((len(input_list))/2)-1)*
*    else:*
*        return (int((len(input_list)/2)-1)-1,int((len(input_list))/2)-1)*
*# 1 is subtracted from both because python indicies start at 0 *

*def Middlearray(input_list, data):*
*    mid = findMiddle(input_list)*
    
*    if isinstance(mid, int) == False:#if there is two mid values*
*        li = input_list*
*        limid=li[int(mid[0]-(len(data)/2)):mid[0]]*
*        limid2 = li[mid[1]:int(mid[1]+(len(data)/2))]*
*        convsame=np.hstack((limid,limid2))*
*    else:#if there is one mid value *
*        li = input_list *
*        convsame = li[int(mid-(len(data)/2)):int(mid+(len(data)/2))]*
        
    
*    if len(convsame) == len(data):*
*        return convsame*
*    else:*
*        return -inf*

My problem i need some way to obtain the output from the convolution not 
just as an object but an array for this to work. Is it possible to extract 
the values of the convolution output so i can obtain the border_mode='same' 
result? i also noticed that theano.tensor .nnet.conv2d has 
border_mode='half' which is similar to what i need. Is the syntax 
transferable between the two functions? currently i write my convolution as 

* 
convol=theano.tensor.signal.conv.conv2d(muJ[None,:],transfer[None,:],(1,100),(1,100),border_mode='full')*

Where muJ is my data and transfer is my function/filter, both have a length 
of 100. 

-- 

--- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/theano-users/e17b3977-46d1-45e1-854d-adff91c2f00f%40googlegroups.com.

Reply via email to