@@ -634,6 +634,23 @@ public static Tensor[] _SqrtGrad(Operation op, Tensor[] grads)
634634 } ) ;
635635 }
636636
637+ [ RegisterGradient ( "Asin" ) ]
638+ public static Tensor [ ] _ASinGrad ( Operation op , Tensor [ ] grads )
639+ {
640+ var grad = grads [ 0 ] ;
641+ var x = op . inputs [ 0 ] ;
642+
643+ return tf_with ( ops . control_dependencies ( grads ) , delegate
644+ {
645+ x = math_ops . conj ( x ) ;
646+ // the derivative of
647+ // y = asin(x)
648+ // is
649+ // d/dx asin(x) = 1 / sqrt(1-x*x)
650+ return new Tensor [ ] { math_ops . multiply ( grad , 1 / gen_math_ops . sqrt ( 1 - gen_math_ops . square ( x ) ) ) } ;
651+ } ) ;
652+ }
653+
637654 [ RegisterGradient ( "Sin" ) ]
638655 public static Tensor [ ] _SinGrad ( Operation op , Tensor [ ] grads )
639656 {
@@ -660,6 +677,23 @@ public static Tensor[] _SinhGrad(Operation op, Tensor[] grads)
660677 } ) ;
661678 }
662679
680+ [ RegisterGradient ( "Acos" ) ]
681+ public static Tensor [ ] _ACosGrad ( Operation op , Tensor [ ] grads )
682+ {
683+ var grad = grads [ 0 ] ;
684+ var x = op . inputs [ 0 ] ;
685+
686+ return tf_with ( ops . control_dependencies ( grads ) , delegate
687+ {
688+ // the derivative of
689+ // y = acos(x)
690+ // is
691+ // d/dx acos(x) = -1 / sqrt(1-x*x) = -d/dx asin(x)
692+ x = math_ops . conj ( x ) ;
693+ return new Tensor [ ] { math_ops . multiply ( grad , - 1 / gen_math_ops . sqrt ( 1 - gen_math_ops . square ( x ) ) ) } ;
694+ } ) ;
695+ }
696+
663697 [ RegisterGradient ( "Cos" ) ]
664698 public static Tensor [ ] _CosGrad ( Operation op , Tensor [ ] grads )
665699 {
@@ -686,6 +720,23 @@ public static Tensor[] _CoshGrad(Operation op, Tensor[] grads)
686720 } ) ;
687721 }
688722
723+ [ RegisterGradient ( "Atan" ) ]
724+ public static Tensor [ ] _ATanGrad ( Operation op , Tensor [ ] grads )
725+ {
726+ var grad = grads [ 0 ] ;
727+ var x = op . inputs [ 0 ] ;
728+
729+ return tf_with ( ops . control_dependencies ( grads ) , delegate
730+ {
731+ // the derivative of
732+ // y = atan(x)
733+ // is
734+ // d/dx atan(x) = 1 / (1 + x*x)
735+ x = math_ops . conj ( x ) ;
736+ return new Tensor [ ] { math_ops . multiply ( grad , 1 / ( 1 + gen_math_ops . square ( x ) ) ) } ;
737+ } ) ;
738+ }
739+
689740 [ RegisterGradient ( "Tanh" ) ]
690741 public static Tensor [ ] _TanhGrad ( Operation op , Tensor [ ] grads )
691742 {
0 commit comments