MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / StopGradient

Function StopGradient

tensorflow/go/op/wrappers.go:2225–2237  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

2223// * Adversarial training, where no backprop should happen through the adversarial
2224// example generation process.
2225func 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//

Callers 3

TEST_FFunction · 0.85
CheckGradMethod · 0.85
CheckGradMethod · 0.85

Calls 3

ErrMethod · 0.45
AddOperationMethod · 0.45
OutputMethod · 0.45

Tested by 3

TEST_FFunction · 0.68
CheckGradMethod · 0.68
CheckGradMethod · 0.68