Theano/Theano — pull request #1755 by benanne (2014-02-27 16:30:23+00:00)
Title: added consider_constant op

This adds the *theano.tensor.consider_constant* op, which causes the gradient for a given expression to be truncated to 0. It has the same functionality as the *consider_constant* keyword argument of *theano.tensor.grad*, but it allows for more flexibility. For example, it is possible to use the same subexpression in a given expression multiple times, where the gradient is only backpropagated through some of the instances of the subexpression, but is truncated for other instances (those wrapped with the *consider_constant* op).

I wasn't sure what module I should put this in, so I went with *theano.tensor.extra_ops*. There is also an optimization that removes the op from the graph to make sure all the right optimizations can be applied. I added a basic docstring and two tests, one that verifies correctness of gradients, and one that verifies that the op is removed from the graph by the optimization.