Search code examples
pythontheano

Theano force tensor elements to be value


I have a theano tensor W. I want to force some elements of W to be 2. How do I do it? I know that theano TensorVariable does not support item assignment. Is it not possible to do this? I can not use a shared variable for it as W is derived from another theano variable.


Solution

  • You can try set_subtensor in theano.tensor. The example provided there should hopefully be sufficiently clear.