Ahmed Osman
Ahmed Osman

Reputation: 94

Stopping Gradients for a subset of a tensor in tensorflow

I have a tensorflow graph already set, an input variable (x = tf.Variable() ) and the resulting error term (err). I would like to be able to update on a subset of the elements in x.

One way is using tf.stop_gradient(), however this will require rebuilding the graph again from scratch apply the stop gradient operator. Is their a way to do this without having to go through rebuilding the graph.

Upvotes: 0

Views: 189

Answers (1)

P-Gn
P-Gn

Reputation: 24651

If you can't rebuild the graph, a solution could be to save values of x prior to the update, and later to tf.assign those values back to the elements of x that you want to preserve.

Upvotes: 1

Related Questions