Does theano cache previous results by default? I've noticed that running large datasets and switching between functions costs more memory than if I call the same function on the datasets multiple times, even if all the functions do the same thing.

For example:

x = T.fmatrix()
y = T.fmatrix()
z = T.fmatrix()
a = T.fscalar()
b = T.fscalar()
c = T.fscalar()
d = T.fscalar()
e = T.iscalar()

data = np.arange(36000000).reshape(6000,6000)
data2 = np.arange(36000000).reshape(6000,6000)

srng = T.shared_randomstreams.RandomStreams(seed=np.random.random_integers(0, 2**30))
f1 = theano.function([x,y, z, a, b,c,e], [\
(z + (srng.uniform(size=T.shape(z)) * b * c *\
T.extra_ops.repeat(x.dimshuffle(1,0), e,1))+\
(np.float32(0.5)* srng.uniform(size=T.shape(z)) * a * c**2 *\
T.extra_ops.repeat(y.dimshuffle(1,0), e,1)))],allow_input_downcast=True)

Calling f1 on the datasets doesn't give a memory error but calling f1, then f2, then several other functions that do the same thing as f1 does. This was a test for my actual code, which has many functions (which do not all do the same thing) and runs into memory errors really easily.

Is caching the reason for this? And if so, can I flush the cache or disable it completely? Are there any other ways to optimize theano code?

(Sorry if I'm rambling...first time posting to a forum)

asked Jul 08 '14 at 14:16

Lin%20Xu's gravatar image

Lin Xu
1111

Be the first one to answer this question!
toggle preview

powered by OSQA

User submitted content is under Creative Commons: Attribution - Share Alike; Other things copyright (C) 2010, MetaOptimize LLC.