Skip to content

Commit

Permalink
fix: add the gradient of the tf.gradient opr
Browse files Browse the repository at this point in the history
  • Loading branch information
“Wanglongzhi2001” committed Jul 26, 2023
1 parent ab7b986 commit 005476c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/TensorFlowNET.Core/Gradients/array_grad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,5 +373,13 @@ public static Tensor[] _TransposeGrad(Operation op, Tensor[] grads)
var p = op.inputs[1];
return new Tensor[] { array_ops.transpose(grads[0], array_ops.invert_permutation(p)), null };
}

[RegisterGradient("ReverseV2")]
public static Tensor[] _ReverseV2Grad(Operation op, Tensor[] grads)
{
var grad = grads[0];
var axis = op.inputs[1];
return new Tensor[] { array_ops.reverse(grad, axis), null };
}
}
}

0 comments on commit 005476c

Please sign in to comment.