@@ -1348,8 +1348,18 @@ public extension Tensor where Scalar : Numeric {
1348
1348
wrt: self , vjp: _vjpMean ( alongAxes: )
1349
1349
where Scalar : TensorFlowFloatingPoint
1350
1350
)
1351
+ func mean( alongAxes axes: Tensor < Int32 > ) -> Tensor {
1352
+ return Raw . mean ( self , reductionIndices: axes, keepDims: true )
1353
+ }
1354
+
1355
+ /// Returns the arithmetic mean along the specified axes. The reduced
1356
+ /// dimensions are retained with value 1.
1357
+ /// - Parameter axes: The dimensions to reduce.
1358
+ /// - Precondition: Each value in `axes` must be in the range `-rank..<rank`.
1359
+ @inlinable @inline ( __always)
1360
+ @differentiable ( wrt: self where Scalar : TensorFlowFloatingPoint)
1351
1361
func mean( alongAxes axes: [ Int32 ] ) -> Tensor {
1352
- return Raw . mean ( self , reductionIndices : Tensor < Int32 > ( axes) , keepDims : true )
1362
+ return mean ( alongAxes : Tensor < Int32 > ( axes) )
1353
1363
}
1354
1364
1355
1365
/// Returns the arithmetic mean along the specified axes. The reduced
@@ -1401,12 +1411,22 @@ public extension Tensor where Scalar : Numeric {
1401
1411
/// - Precondition: Each value in `axes` must be in the range `-rank..<rank`.
1402
1412
@inlinable @inline ( __always)
1403
1413
@differentiable ( wrt: self where Scalar : TensorFlowFloatingPoint)
1404
- func variance( alongAxes axes: [ Int32 ] ) -> Tensor {
1414
+ func variance( alongAxes axes: Tensor < Int32 > ) -> Tensor {
1405
1415
let mean = self . mean ( alongAxes: axes)
1406
1416
let squaredDiff = ( self - mean) . squared ( )
1407
1417
return squaredDiff. mean ( alongAxes: axes)
1408
1418
}
1409
1419
1420
+ /// Returns the variance along the specified axes. The reduced dimensions are
1421
+ /// retained with value 1. Does not apply Bessel's correction.
1422
+ /// - Parameter axes: The dimensions to reduce.
1423
+ /// - Precondition: Each value in `axes` must be in the range `-rank..<rank`.
1424
+ @inlinable @inline ( __always)
1425
+ @differentiable ( wrt: self where Scalar : TensorFlowFloatingPoint)
1426
+ func variance( alongAxes axes: [ Int32 ] ) -> Tensor {
1427
+ return variance ( alongAxes: Tensor < Int32 > ( axes) )
1428
+ }
1429
+
1410
1430
/// Returns the product along the specified axes. The reduced dimensions are
1411
1431
/// retained with value 1.
1412
1432
/// - Parameter axes: The dimensions to reduce.
0 commit comments