Hi Guy,

Thanks again for raising these issues.  This is the status as I see it

Presently I am trying to use the mapping between Theano and SymPy
> (sympy.printing.theanocode theano_function) to make my callable functions
> and take advantage of the optimization routines. I have two major problems
> and a few questions:
>
> 1st major problem: Though piecewise functions exist in SymPy
> (sympy.functions.elementary.piecewise) there is no counterpart in Theano.
> Looking at the source of the inspiration for theanocode (
> https://github.com/nouiz/theano_sympy/    graph_translation.py) I see
> that some of the SymPy equivalents were defined as lambda functions. Is
> there an equivalent way to add Theano conditional expressions wrapped into
> a function to add to the mapping dictionary in theanocode.py?
>

This is in https://github.com/sympy/sympy/pull/2366 and should hopefully
soon be merged.


> 2nd major problem: Similar to the problem above in that I am not sure that
> the Theano counterpart is; some of the terms that I use are interpolated
> functions (with one ODE variable as input) that we have wrapped
> symbolically while providing a numerical implementation (so that symbolic
> derivatives can be made, resulting in their own interpolations). Is it
> possible to recreate the interpolation function as a Theano operation for
> use within the system of ODEs?
>

I'm not sure I fully understand this piece.  Is it possible to define your
interpolation scheme with lower-level operators such as with Piecewise and
polynomials?  What is your interpolation scheme?

Remain questions:
> I presently have to flatten my input to theano_function to a list of
> expressions and then wrap to return to a form (Jacobian is a matrix not a
> vector); is it possible to have a matrix of different expressions as an
> input to theano_function with a vector output?
>

Jason answered this I think.  In the dev version theano_function should be
able to take SymPy matrices as inputs.  See the description of this PR for
an example https://github.com/sympy/sympy/pull/2013

I know that a huge amount of Theano speed up is due to parallelization of
> matrix operations (which I do not have), should I be focusing on SymPy
> Autowrap/Ufuncify or my own code generation instead of trying to get Theano
> to play nicely?
>

I find your engagement of the SymPy-Theano connection valuable and am happy
to support it.  I think you'll find autowrap/ufuncify possibly more mature
but less well supported.


> Stupid questions:
> Does sympy.printing.theanocode.theano_function automatically optimize the
> compiled graph?
>

Answered: yes


> Minor comment:
> Perhaps unnecessary for most uses of the theano_function, but I needed to
> modify function inputs so as to be able to use the keyword argument
> 'on_unused_input=ignore' as opposed to 'raise' so that I did not need to
> have all symbols in all equations. This may be avoided by having the unused
> symbols somehow (I don't know how) included in each expression.
>

Answered: In PR https://github.com/sympy/sympy/pull/2358

> With regards to using an externally defined theano graph or op (theano
wrapped sympy implementation), how would one  pass them to theano_function?
It feels as though it would be analogous to the autowrap helpers argument,
or would this be an issue of merging graphs before calling theano.function?
If I can understand this step, I feel as though both of my problems would
be solvable (a wrapping of a piecewise along with a wrapping of an
interpolated function)

Answered: use theano_code

> With the example above of having an implemented function in some
expression in sympy, assuming one can write the c-code equivalent, how
would one link the c-code to the codegen process as opposed to having
codegen generate it?

I don't think we can do this.  If you have C implementations of operations
within SymPy that aren't yet supported we'd love help with this.  See
https://github.com/sympy/sympy/pull/2369

In general let us know how you're doing with this project and what is
keeping you from making progress.

-Matt

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to