From bd51c8494d56a510d8258a22838bfe4ba0461c0b Mon Sep 17 00:00:00 2001 From: dataangel Date: Thu, 21 Jan 2021 20:16:53 +0800 Subject: [PATCH] update:Gradients/nn_grad.cs --- src/TensorFlowNET.Core/Gradients/nn_grad.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/TensorFlowNET.Core/Gradients/nn_grad.cs b/src/TensorFlowNET.Core/Gradients/nn_grad.cs index 13acd33f..202558d3 100644 --- a/src/TensorFlowNET.Core/Gradients/nn_grad.cs +++ b/src/TensorFlowNET.Core/Gradients/nn_grad.cs @@ -111,7 +111,7 @@ namespace Tensorflow.Gradients "implementation's interaction with tf.gradients()"); var grad_0 = grads[0]; - + return new Tensor[] { _BroadcastMul(grad_0, sparse_softmax_grad_without_gradient), @@ -119,6 +119,18 @@ namespace Tensorflow.Gradients }; } + [RegisterGradient("SquaredDifference")] + public static Tensor[] _SquaredDifferenceGrad(Operation op, Tensor[] grads) + { + //"""Returns the gradient for (x-y)^2.""" + Tensor x = op.inputs[0]; + Tensor y = op.inputs[1]; + return new Tensor[] + { + x, + y + }; + } /// /// Gradient function for Conv2D. ///