Reusing Theano Compiled Features

Suppose Theano has the following function:

import theano.tensor as T from theano import function x = T.dscalar('x') y = T.dscalar('y') z = x + y f = function([x, y], z) 

When I try to run it, a calculation graph is built, the function is optimized and compiled.

How can I reuse this compiled code snippet from a Python script and / or C ++ application?

EDIT: The goal is to create a deep learning network and reuse it in a final C ++ application.

+8
c ++ theano
source share
1 answer

This is currently not possible. There is a user who modified Theano to allow the Theano function to be etched, but during the scattering we already optimized the graph.

There is a Pull request that allows Theano to generate a C ++ library. Then the user can compile it himself and use it as a regular C ++ library. The lib links to python lib and require the installation of numpy. But it is not ready for widespread use.

What is your goal? Save compilation time? If so, Anano already caches the C ++ module that it compiles, so compiling will be faster the next time you use it. But for a large graph, the optimization phase is always redone, as mentioned above, and this can take considerable time.

So what is your goal?

This is what we are working on. Be sure to use the latest version of Theano (0.6) as it compiles faster. The development version is also slightly faster.

+7
source share

All Articles