Trait dfdx::tensor_ops::VarTo

source ·
pub trait VarTo: HasErr + HasShape {
    // Required method
    fn try_var<Dst: Shape, Ax: Axes>(
        self
    ) -> Result<Self::WithShape<Dst>, Self::Err>
       where Self::Shape: HasAxes<Ax> + ReduceShapeTo<Dst, Ax>;

    // Provided method
    fn var<Dst: Shape, Ax: Axes>(self) -> Self::WithShape<Dst>
       where Self::Shape: HasAxes<Ax> + ReduceShapeTo<Dst, Ax> { ... }
}
Expand description

Reduction alogn multiple axes using variance

Required Methods§

source

fn try_var<Dst: Shape, Ax: Axes>( self ) -> Result<Self::WithShape<Dst>, Self::Err>where Self::Shape: HasAxes<Ax> + ReduceShapeTo<Dst, Ax>,

Fallible version of VarTo::var

Provided Methods§

source

fn var<Dst: Shape, Ax: Axes>(self) -> Self::WithShape<Dst>where Self::Shape: HasAxes<Ax> + ReduceShapeTo<Dst, Ax>,

Result Tensor has smaller number of dimensions.

Pytorch equivalent: t.var(Axes, unbiased=False)

Examples:

let t = dev.tensor([[2.0f32, 3.0, 4.0], [3.0, 6.0, 9.0]]);
let r = t.var::<Rank1<2>, _>(); // or `var::<_, Axis<1>>()`
assert_eq!(r.array(), [0.6666667, 6.0]);

Implementors§

source§

impl<S: Shape, E: Dtype, D: Device<E>, T: Tape<E, D>> VarTo for Tensor<S, E, D, T>