[theano-users] Constraints on convolutional filters

2017-08-17 Thread Sym
I would like to add a constraint on the filters of my convolution operator, 
such that they'll always be symmetric and positive semi definite along the 
two trailing (spatial) axes.

There are many ways to achieve this, for instance taking the Gaussian 
Kernels, or building the symmetric Gram Matrices of the filters.

To ensure that this conditions is always met throughout the network 
training, I'm applying this transformation to the filters before every 
convolution.

The filters will then be modified between an update and a forward step ! I 
am not sure it's a good idea...



*My questions :*Will the network be able to learn if the filters are passed 
through this transformation at each forward step ?

Is there another way to constrain the filters of a layer on some condition?

-- 

--- 
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.


[theano-users] Meaning of this error message

2017-07-10 Thread Sym
I don't understand the following error message, any help would be 
appreciated !!
















*ERROR (theano.gof.opt): Optimization failure due to: constant_foldingERROR 
(theano.gof.opt): node: Assert{msg='Theano Assert 
failed!'}(TensorConstant{0.0}, TensorConstant{False})ERROR 
(theano.gof.opt): TRACEBACK:ERROR (theano.gof.opt): Traceback (most recent 
call last):  File 
"/Users/mcomin/anaconda/lib/python3.5/site-packages/theano/gof/opt.py", 
line 1982, in process_nodereplacements = lopt.transform(node)  File 
"/Users/mcomin/anaconda/lib/python3.5/site-packages/theano/tensor/opt.py", 
line 6452, in constant_foldingrequired = thunk()  File 
"/Users/mcomin/anaconda/lib/python3.5/site-packages/theano/gof/op.py", line 
843, in rvalfill_storage()  File 
"/Users/mcomin/anaconda/lib/python3.5/site-packages/theano/gof/cc.py", line 
1698, in __call__reraise(exc_type, exc_value, exc_trace)  File 
"/Users/mcomin/anaconda/lib/python3.5/site-packages/six.py", line 686, in 
reraiseraise valueAssertionError: Theano Assert failed!*

Traceback (most recent call last):

[... I removed the traceback for brevity... ]

*AssertionError: ('The following error happened while compiling the node', 
forall_inplace,cpu,scan_fn}(TensorConstant{2}, TensorConstant{[0 1]}, 
IncSubtensor{InplaceSet;:int64:}.0, IncSubtensor{InplaceSet;:int64:}.0, 
IncSubtensor{InplaceSet;:int64:}.0, W, gamma, beta, W, b, W, b, W, b, W, b, 
W, b, W, b, W, b, W, b, W, b, noise, InplaceDimShuffle{x,0,x}.0, 
InplaceDimShuffle{0,1,x,2}.0, InplaceDimShuffle{x,0,x}.0, 
InplaceDimShuffle{0,1,x,2}.0, InplaceDimShuffle{x,0,x}.0, 
InplaceDimShuffle{0,1,x,2}.0, InplaceDimShuffle{x,0,x}.0, 
InplaceDimShuffle{0,1,x,2}.0, InplaceDimShuffle{x,0,x}.0, 
InplaceDimShuffle{0,1,x,2}.0, InplaceDimShuffle{x,0,x}.0, 
InplaceDimShuffle{0,1,x,2}.0, InplaceDimShuffle{x,0,x}.0, 
InplaceDimShuffle{0,1,x,2}.0, InplaceDimShuffle{x,0,x}.0, 
InplaceDimShuffle{0,1,x,2}.0, InplaceDimShuffle{x,0,x}.0, 
InplaceDimShuffle{0,1,x,2}.0, InplaceDimShuffle{x,0,x}.0, 
InplaceDimShuffle{x,0,x}.0, Subtensor{::, ::, int64}.0, mean, 
Elemwise{mul,no_inplace}.0, Elemwise{inv,no_inplace}.0, 
Elemwise{mul,no_inplace}.0), '\n', 'The following error happened while 
compiling the node', forall_inplace,cpu,scan_fn}(TensorConstant{2}, 
Elemwise{Composite{OR(EQ(i0, i1), EQ(i0, i1))}}.0, TensorConstant{[0 1]}, 
IncSubtensor{InplaceSet;:int64:}.0, IncSubtensor{InplaceSet;:int64:}.0, 
IncSubtensor{InplaceSet;:int64:}.0, ScalarFromTensor.0, 
InplaceDimShuffle{x,0,x}.0, InplaceDimShuffle{0,1,x,2}.0, 
InplaceDimShuffle{x,0,x}.0, InplaceDimShuffle{0,1,x,2}.0, 
InplaceDimShuffle{x,0,x}.0, InplaceDimShuffle{0,1,x,2}.0, 
InplaceDimShuffle{x,0,x}.0, InplaceDimShuffle{0,1,x,2}.0, 
InplaceDimShuffle{x,0,x}.0, InplaceDimShuffle{0,1,x,2}.0, 
InplaceDimShuffle{x,0,x}.0, InplaceDimShuffle{0,1,x,2}.0, 
InplaceDimShuffle{x,0,x}.0, InplaceDimShuffle{0,1,x,2}.0, 
InplaceDimShuffle{x,0,x}.0, InplaceDimShuffle{0,1,x,2}.0, 
InplaceDimShuffle{x,0,x}.0, InplaceDimShuffle{0,1,x,2}.0, 
InplaceDimShuffle{x,0,x}.0, InplaceDimShuffle{x,0,x}.0, Subtensor{::, ::, 
int64}.0, Elemwise{mul,no_inplace}.0, Elemwise{Mul}[(0, 1)].0, 
Elemwise{Composite{inv(sqrt((i0 + (i1 * i2}}[(0, 2)].0, 
Elemwise{mul,no_inplace}.0), '\n', 'Theano Assert failed!')*



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.
For more options, visit https://groups.google.com/d/optout.


Re: [theano-users] And operator doesn't work with theano logical operators

2017-07-04 Thread Sym
I clearly haven't searched enough for theano.tensor.and_ ! 

Thank you for the correction, everything is clear now :)

-- 

--- 
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.


[theano-users] Re: Compiled cost function (with theano.function) ?

2017-07-04 Thread Sym
I would like to add that the cost function is looping over the input 
tensors.

I need these loops to be differentiable, so I've implemented them with 
scan/map. But in  this answer 
<https://groups.google.com/forum/#!msg/theano-users/uqYtNlpwiHw/k-3QCro0SbkJ> 
I saw that it is possible to compile a theano function and call it with a 
Python for loop. 

So again I don't know what's best.. Should I compile a step of the loop in 
a theano function, and then loop with Python's for op ?
Or should I compile a theano function with the whole cost (where the loops 
are now done with scan) ?
Or should I just compile one theano function, with the network and the cost 
?


Thank you for your help !








Le mardi 4 juillet 2017 10:20:17 UTC-4, Sym a écrit :
>
> Hi,
>
> I have a fairly complex cost function,  composed of various pieces that 
> are looping over the data.
>
> Should I compile the total cost as a theano function or not ?
> Would the network still be able to compute gradients if I do this ?
> Would it be faster / slower than compiling everything (network + cost 
> functions) in one theano function ?
>
> I am not sure about what would be the benefits of doing this, if there are 
> any.
>

-- 

--- 
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.


Re: [theano-users] And operator doesn't work with theano logical operators

2017-06-29 Thread Sym
I found a solution :

The and operator should be implemented with * and the or operator with +, 
as the python operators do no work properly with theano (as opposed to what 
they say in the docs).

For further readers, the corrected code is :

import theano
import theano.tensor as T
import numpy as np
import matplotlib.pyplot as plt

r = T.scalar()
gate = T.switch( T.ge(r,2.) * T.le(r,3.) , 1., 0.)
f = theano.function([r],gate)
x = np.arange(0.,4.,0.05,dtype='float32')
y = [f(i) for i in x]
plt.plot(x,y)

Which indeed gives the correct output.

-- 

--- 
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.


Re: [theano-users] And operator doesn't work with theano logical operators

2017-06-29 Thread Sym
I am using theano 0.9.0 and this function does not exist.. I can't find it 
in the documentation either !

And in the theano docs it says that :
__{abs,neg,lt,le,gt,ge,invert,and,or,add,sub,mul,div,truediv,floordiv}__
Those elemwise operation are supported via Python syntax.

Le mercredi 28 juin 2017 21:15:37 UTC-4, nouiz a écrit :
>
> Don't use the Python "and" operation. Use theano.tensor.and(a,b) instead. 
> I think it will fix your problem.
>
> Le mer. 28 juin 2017 10:26, Sym <mass.c...@gmail.com > a 
> écrit :
>
>>
>> I want to build a piecewise function with theano, for instance a function 
>> that is nonzero only in the interval [2,3].
>>
>> Here is the minimal code reproducing the error : 
>>
>>
>> import theano
>> import theano.tensor as T
>> import numpy as np
>> import matplotlib.pyplot as plt
>>
>> r = T.scalar()
>> gate = T.switch( T.ge(r,2.) and T.le(r,3.) , 1., 0.)
>> f = theano.function([r],gate)
>> x = np.arange(0.,4.,0.05,dtype='float32')
>> y = [f(i) for i in x]
>> plt.plot(x,y)
>>
>>  
>>
>> The result is the following : https://i.stack.imgur.com/XMQme.png 
>>
>> Which is clearly not correct : only one condition is satisfied here.
>>
>>
>> If I replace T.switch by theano.ifelse.ifelse the result is the same...
>>
>> Is it a known bug, or am I missing something here?
>>
>>
>> Thanks a lot !
>>
>> -- 
>>
>> --- 
>> 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...@googlegroups.com .
>> For more options, visit 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.


[theano-users] Re: How can I calculate the size of output of convolutional operation in theano?

2017-06-28 Thread Sym
You should check this out 
http://deeplearning.net/software/theano_versions/dev/tutorial/conv_arithmetic.html

The output size is in general o = (i - r + 2p)/s + 1 where i is the input 
size, o the output size, r the filter size, p the padding and s the stride 
of the convolution. This formula holds for every dimension (so for a 2D 
convolution, if the strides, padding, filters, etc.. are different you can 
apply this formula separately)

Le lundi 26 juin 2017 15:36:21 UTC-4, Sunjeet Jena a écrit :
>
> Is there any way I can calculate the size of the output after the 
> Convolution Operation?
>

-- 

--- 
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.