Stops gradient computation. When executed in a graph, this op outputs its input tensor as-is. When building ops to compute gradients, this op prevents the contribution of its inputs to be taken into account. Normally, the gradient generator adds ops to a graph to compute the derivatives of a spec
(scope *Scope, input tf.Output)
| 2223 | // * Adversarial training, where no backprop should happen through the adversarial |
| 2224 | // example generation process. |
| 2225 | func StopGradient(scope *Scope, input tf.Output) (output tf.Output) { |
| 2226 | if scope.Err() != nil { |
| 2227 | return |
| 2228 | } |
| 2229 | opspec := tf.OpSpec{ |
| 2230 | Type: "StopGradient", |
| 2231 | Input: []tf.Input{ |
| 2232 | input, |
| 2233 | }, |
| 2234 | } |
| 2235 | op := scope.AddOperation(opspec) |
| 2236 | return op.Output(0) |
| 2237 | } |
| 2238 | |
| 2239 | // Identity op for gradient debugging. |
| 2240 | // |