1- using System ;
1+ using NumSharp . Core ;
2+ using System ;
23using System . Collections . Generic ;
34using System . Text ;
45
@@ -37,8 +38,8 @@ public static Tensor cast(Tensor x, TF_DataType dtype = TF_DataType.DtInvalid, s
3738 /// <param name="name"> A name for the operation (optional).</param>
3839 public static Tensor reduce_mean ( Tensor input_tensor , int [ ] axis = null , bool keepdims = false , string name = null )
3940 {
40- var r = _ReductionDims ( input_tensor , new Tensor ( axis ) ) ;
41- var m = gen_math_ops . mean ( input_tensor , r ) ;
41+ var r = _ReductionDims ( input_tensor , axis ) ;
42+ var m = gen_math_ops . mean ( input_tensor , ( int [ ] ) r , keepdims , name ) ;
4243 return _may_reduce_to_scalar ( keepdims , axis , m ) ;
4344 }
4445 /// <summary>
@@ -135,8 +136,8 @@ private static Tensor _ReductionDims(Tensor x, Tensor axis)
135136 return range ( 0 , rank , 1 ) ;
136137 }
137138 }
138-
139- private static int [ ] _ReductionDims ( Tensor x , int [ ] axis )
139+
140+ private static object _ReductionDims ( Tensor x , int [ ] axis )
140141 {
141142 if ( axis != null )
142143 {
@@ -147,12 +148,12 @@ private static int[] _ReductionDims(Tensor x, int[] axis)
147148 var rank = array_ops . rank ( x ) ;
148149 if ( rank != null )
149150 {
150- // return constant_op.constant();
151+ return constant_op . constant ( np . arange ( rank ) , TF_DataType . TF_INT32 ) ;
151152 }
152- // return range(0, rank, 1);
153- throw new NotFiniteNumberException ( ) ;
153+ return range ( 0 , rank , 1 ) ;
154154 }
155155 }
156+
156157
157158 public static Tensor range ( object start , object limit = null , object delta = null , TF_DataType dtype = TF_DataType . DtInvalid , string name = "range" )
158159 {
0 commit comments