Skip to content

Commit 7fec40b

Browse files
authored
Merge pull request #1159 from Wanglongzhi2001/master
fix: add the gradient of the tf.gradient opr
2 parents ab7b986 + 005476c commit 7fec40b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/TensorFlowNET.Core/Gradients/array_grad.cs

+8
Original file line numberDiff line numberDiff line change
@@ -373,5 +373,13 @@ public static Tensor[] _TransposeGrad(Operation op, Tensor[] grads)
373373
var p = op.inputs[1];
374374
return new Tensor[] { array_ops.transpose(grads[0], array_ops.invert_permutation(p)), null };
375375
}
376+
377+
[RegisterGradient("ReverseV2")]
378+
public static Tensor[] _ReverseV2Grad(Operation op, Tensor[] grads)
379+
{
380+
var grad = grads[0];
381+
var axis = op.inputs[1];
382+
return new Tensor[] { array_ops.reverse(grad, axis), null };
383+
}
376384
}
377385
}

0 commit comments

Comments
 (0)