Looking at your code it's difficult for me to see what you're doing with
the cache.  It looks like you're trying to fill it with a particular value
so that SymPy's theano_function call latches onto something you've already
built.

Instead, I recommend that you use theano_code, to transform individual
sympy expressions into Theano variables like so

theano_inps = [theano_code(inp) for inp in inplist]
theano_outs = [theano_code(expr) for expr in exprlist]

Then, if you want to build more Theano expressions with your custom Theano
op you can do so in standard Theano using these standard Theano variables.
 I think that this will be simpler than reverse engineering a caching
system in order to inject a pre-built theano variable into the graph.

In short, only use theano_function if you're only using pure SymPy.  If
you're doing more complex things then translate your SymPy expressions to
Theano expressions and work in pure Theano from then on.



On Thu, Aug 22, 2013 at 5:15 PM, Guy Parsey <guy.par...@gmail.com> wrote:

> That is precisely what I don't understand. In your example we are
> neglecting to give the function all of its inputs and the error message:
>
> MissingInputError: ('An input of the graph, used to compute
> Elemwise{add,no_inplace}(x, y), was not provided and not given a value', y)
>
> is saying that we have forgotten the y input. In the test case I am doing,
> which yields the message:
>
> MissingInputError: ('An input of the graph, used to compute
> TheanoInterpWrapOp.theanointerp(y), was not provided and not given a
> value', y)
>
> Though the message is practically identical, when running the test case
> with my verbose print statements, the following is printed before being
> passed to the Op pulled from the TheanoPrinter.cache
> children:  [y]
> child types:  [<class 'theano.tensor.basic.TensorVariable'>]
> followed by the return line:
>
> self.cache[newkey](*children)
>
> where self.cache[newkey] is the theano op. Doesn't this mean that the
> theano variable y is being passed to the theano Op or does this y not carry
> a value? Instead of passing the theano variable y to the op, should I be
> passing it to a theano.function of the Op?
> Cheers,
> Guy
>
> On Thursday, August 22, 2013 6:01:17 PM UTC-4, Matthew wrote:
>
>> Here is a printout of the error message:
>>
>> MissingInputError: ('An input of the graph, used to compute
>> TheanoInterpWrapOp.**theanointerp(y), was not provided and not given a
>> value', y)
>>
>> What this says is that some nodes in your graph 
>> (TheanoInterpWrapOp.**theanointerp(y),)
>> weren't given access to all of the inputs that they needed.  This would
>> happen in Theano if, for example,
>>
>> x = theano.tensor.vector('x')
>> y = theano.tensor.vector('y')
>> z = x + y
>> f = theano.function([x], [z])
>>
>> Notice that we're only giving function x and asking it to compute z.
>>  This code will produce a similar error to what you're receiving.
>>
>>
>> On Thu, Aug 22, 2013 at 4:58 PM, Guy Parsey <guy.p...@gmail.com> wrote:
>>
>>> Correction (independent of testing the theano op), 's' is a simple
>>> wrapper to the spline function, it is not the sympy wrapper. the sympy
>>> wrapper is K and can be evaluated as
>>> In [17]: K._imp_(4.0)
>>> Out[17]: array(16.0)
>>>
>>> On Thursday, August 22, 2013 5:44:35 PM UTC-4, Guy Parsey wrote:
>>>>
>>>> Hey Matt,
>>>> I am pretty sure that I have tested the theano Op separately from
>>>> Sympy, but again, I am probably missing something silly.
>>>> After running the test cases, or evaluating
>>>>   k = TestInterpOp()
>>>>   k.CreateSuite()
>>>> from the SymPy_Theano_KGM_indep.py file, one can run the following lines
>>>>
>>>> In [2]: s,K,Kp = k.SymInterp()
>>>>
>>>> In [3]: op = k.TheanoInterpOp()
>>>>
>>>> In [4]: x = theano.tensor.dvector()
>>>>
>>>> In [5]: f = theano.function([x],op(x))
>>>>
>>>> In [6]: s(4.0)
>>>> Out[6]: array(16.0)
>>>>
>>>> In [7]: f([4.0])
>>>> Out[7]: array([ 16.])
>>>>
>>>> where 's' is the sympy wrapped spline function (undefined function) and
>>>> 'f' is the theano.function of the theano op created around the spline.
>>>> Is this what you mean?
>>>> Cheers,
>>>> Guy
>>>>
>>>> On Thursday, August 22, 2013 5:18:49 PM UTC-4, Matthew wrote:
>>>>>
>>>>> Have you tested your interpolation op in isolation from SymPy?
>>>>>
>>>>> A quick glance at the error (quick glance means I can easily be wrong)
>>>>> leads me to think that this particular issue is localized within the 
>>>>> domain
>>>>> of Theano.  If this is the case then I recommend asking about your spline
>>>>> op on the thean...@googlegroups.com mailing list.
>>>>>
>>>>>
>>>>> On Thu, Aug 22, 2013 at 3:59 PM, Guy Parsey <guy.p...@gmail.com>wrote:
>>>>>
>>>>>> Hello again everyone,
>>>>>> I thought I understood everything I needed to implement a theano Op
>>>>>> wrapping a scipy spline function through theanocode, but have been 
>>>>>> promptly
>>>>>> proven wrong (and was on a small family vacation).
>>>>>> Firstly, many thanks for the modifications done to theanocode to
>>>>>> allow for Piecewise and Undefined functions. I feel as though everything 
>>>>>> is
>>>>>> in place for me to solve my problem, but I am still either lacking or
>>>>>> mis-undertsanding something with regards to mapping a custom theano Op
>>>>>> through the theanocode.theano_function.
>>>>>>
>>>>>>>
>>>>>> I have created a quick test case to show what I have understood to
>>>>>> date which in my mind should have all the pieces necessary to function
>>>>>> correctly. I have made a small git repository on GitHub in order to share
>>>>>> this example and because I became fed up trying to figure out how to
>>>>>> publicly share a BitBucket repository (academic license-where I am 
>>>>>> hosting
>>>>>> my thesis project-which will be made public once functioning correctly).
>>>>>> https://github.com/gparsey/**KGM**indep_SympyTheanoOp<https://github.com/gparsey/KGMindep_SympyTheanoOp>
>>>>>>
>>>>>> Running:
>>>>>> >>> ipython SymPy_Theano_KGM_indep.py
>>>>>> Evaluates three test cases: f0) simple arithmetic operation, f1)
>>>>>> sympy piecewise into theano and f2) sympy undefined function wrapped 
>>>>>> spline
>>>>>> into theano using a custom theano Op
>>>>>> Third test case crashes with:
>>>>>> <<<MissingInputError: ('An input of the graph, used to compute
>>>>>> TheanoInterpWrapOp.**theanointer**p(y), was not provided and not
>>>>>> given a value', y)
>>>>>>
>>>>>> I apologize in advance for: the verbosity of the test cases (trying
>>>>>> to figure out what is happening within theanocode) using loc_theanocode
>>>>>> (modified sympy.printing.theanocode), the novice nature of my code and
>>>>>> whether I included correct references to the SymPy community. I am pretty
>>>>>> sure that I am either missing something crucial or doing something silly.
>>>>>> Any and all help/comments would be greatly appreciated.
>>>>>> Cheers,
>>>>>> Guy
>>>>>>
>>>>>> --
>>>>>> 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+un...@googlegroups.com.
>>>>>> To post to this group, send email to sy...@googlegroups.com.
>>>>>> Visit this group at 
>>>>>> http://groups.google.com/**group**/sympy<http://groups.google.com/group/sympy>
>>>>>> .
>>>>>> For more options, visit 
>>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>>> .
>>>>>>
>>>>>
>>>>>  --
>>> 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+un...@**googlegroups.com.
>>> To post to this group, send email to sy...@googlegroups.com.
>>> Visit this group at 
>>> http://groups.google.com/**group/sympy<http://groups.google.com/group/sympy>
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>
>>  --
> 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.
>

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