Skip to content

Commit bd51c84

Browse files
dataangelOceania2018
authored andcommitted
update:Gradients/nn_grad.cs
1 parent ceaa09c commit bd51c84

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/TensorFlowNET.Core/Gradients/nn_grad.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,26 @@ public static Tensor[] _SparseSoftmaxCrossEntropyWithLogitsGrad(Operation op, Te
111111
"implementation's interaction with tf.gradients()");
112112

113113
var grad_0 = grads[0];
114-
114+
115115
return new Tensor[]
116116
{
117117
_BroadcastMul(grad_0, sparse_softmax_grad_without_gradient),
118118
null
119119
};
120120
}
121121

122+
[RegisterGradient("SquaredDifference")]
123+
public static Tensor[] _SquaredDifferenceGrad(Operation op, Tensor[] grads)
124+
{
125+
//"""Returns the gradient for (x-y)^2."""
126+
Tensor x = op.inputs[0];
127+
Tensor y = op.inputs[1];
128+
return new Tensor[]
129+
{
130+
x,
131+
y
132+
};
133+
}
122134
/// <summary>
123135
/// Gradient function for Conv2D.
124136
/// </summary>

0 commit comments

Comments
 (0)