Skip to main content

xavier_uniform

Function xavier_uniform 

Source
pub fn xavier_uniform(
    shape: &[usize],
    fan_in: usize,
    fan_out: usize,
    seed: Option<u64>,
) -> Tensor
Expand description

Xavier uniform initialization (Glorot & Bengio, 2010).

Samples from U(-a, a) where a = sqrt(6 / (fan_in + fan_out)). Suitable for tanh and sigmoid activations.

§Arguments

  • shape - Shape of the tensor to initialize
  • fan_in - Number of input features
  • fan_out - Number of output features
  • seed - Optional random seed for reproducibility

§Example

use aprender::nn::init::xavier_uniform;

// Initialize weight for layer with 784 inputs and 256 outputs
let weight = xavier_uniform(&[256, 784], 784, 256, None);