Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easily mix theano and non-theano code in a graph #1784

Closed
twiecki opened this issue Mar 30, 2014 · 6 comments
Closed

Easily mix theano and non-theano code in a graph #1784

twiecki opened this issue Mar 30, 2014 · 6 comments

Comments

@twiecki
Copy link
Contributor

twiecki commented Mar 30, 2014

In pymc3 we have samplers that require the gradient and some that don't. For those that don't need the gradient, we would like to allow users to write their own likelihoods in pure-python code.

Currently they'd have to create a new theano Op for each non-theano function. It would be great if this process would be much simpler. I would imagine that I could either combine python-functions with theano-ops automatically where theano detects it can not see into the function and just treats it as a blackbox Op, or a decorator for a python function that creates a blackbox Op for it.

Is this already possible somehow? If not, what are the chances this would get included?

@abergeron
Copy link
Member

I'd say a basic decorator that makes a theano op out of a function is certainly possible. I even have sample code to do that at #1785.

@nouiz
Copy link
Member

nouiz commented Mar 31, 2014

I didn't review it now. This could work, but it would miss not just the
grad(), but also infer_shape. Theano won't be able to optimize that
function. If the PR is good, I don't have an objection to merge it.

But why the user can't just build a python function, that take as input
Theano variable? If the user want to express something that Theano isn't
great (loop are complex and control logic too). I understand that this op
is better in those case, but if the user can express its function as a
Theano graph, that would be better. So just make sure to document that:)

On Sat, Mar 29, 2014 at 11:58 PM, abergeron notifications@github.comwrote:

I'd say a basic decorator that makes a theano op out of a function is
certainly possible. I even have sample code to do that at #1785#1785
.

Reply to this email directly or view it on GitHubhttps://github.com//issues/1784#issuecomment-39016952
.

@abergeron
Copy link
Member

I know it's missing infer_shape() and that's why I wrote the stuff in the documenation about optimizing problems.

Which is why I also agree with the second paragraph about making a function that builds a symbolic graph. If that is possible, it would be a much better alternative.

@jsalvatier
Copy link
Contributor

@nouiz the big use case is exactly what you describe "If the user want to express something that Theano isn't great (loop are complex and control logic too)".

@jsalvatier
Copy link
Contributor

I strongly support this.

@nouiz
Copy link
Member

nouiz commented Apr 10, 2014

gh-1785 is now merged. So I'll close this. Keep us updated on your finding/usage of it.

@nouiz nouiz closed this as completed Apr 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants