TensorFlow.NET icon indicating copy to clipboard operation
TensorFlow.NET copied to clipboard

Tensorflow.LookupError : No gradient defined for operation 'Rsqrt' (op type: Rsqrt)

Open Tomazzzzz opened this issue 5 years ago • 6 comments

Hello, I am trying to use batch_normalization. I tried 2 way and got the same error. First way: nn_impl.batch_normalization(y, batchMean, batchVar, beta, gamma, epsilon);

Second way: protected Tensor BatchNorm(Tensor x, Tensor gamma, Tensor beta, Tensor movingMean, Tensor movingVar, float eps) { var inv = tf.cast(math_ops.rsqrt(movingVar + eps), x.dtype); inv *= gamma; return x * inv + (beta - movingMean * inv); }

THNX!!!

Tomazzzzz avatar Jul 29 '21 20:07 Tomazzzzz

Hello, Another issue with gradient :( Tensorflow.LookupError : No gradient defined for operation 'Elu' (op type: Elu)

Tomazzzzz avatar Aug 29 '21 07:08 Tomazzzzz

Sovled? batch_normalization trouble -----( version Tensorflow.NET 0.40.1 Tensorflow.Keras 0.5.1) I need your help. like some example code about using BN function in NeuralNetwork Code. Thanks.

UCtreespring avatar Jun 11 '22 06:06 UCtreespring

same thing i used nn_impl.batch_normalization but :No gradient

wx92nlp avatar Jun 13 '22 11:06 wx92nlp

Hello, I have used function where I manually register gradient.

            ops.RegisterGradientFunction("Elu", (oper, out_grads) =>
            {
                var y = oper.outputs[0];
                return new[] { gen_ops.elu_grad(out_grads[0], y) };
            });
        

Tomazzzzz avatar Jun 14 '22 04:06 Tomazzzzz

Hello, I have used function where I manually register gradient.

            ops.RegisterGradientFunction("Elu", (oper, out_grads) =>
            {
                var y = oper.outputs[0];
                return new[] { gen_ops.elu_grad(out_grads[0], y) };
            });
        

Thank you so much!


A custom gradient function? Cool But It doesn't sound easy for me. what a pity. I'm Freshmen, I don't even know where this code should be.

UCtreespring avatar Jun 15 '22 05:06 UCtreespring

@UCtreespring Hi, just call it in constructor before creating/loading graph.

Tomazzzzz avatar Jun 15 '22 05:06 Tomazzzzz