Skip to content

Weight Initializers¤

# WeightInitializers.zeros32Function.

zeros32(::AbstractRNG, size...) = zeros(Float32, size...)

Return an Array{Float32} of zeros of the given size. (rng is ignored)

source

# WeightInitializers.ones32Function.

ones32(::AbstractRNG, size...) = ones(Float32, size...)

Return an Array{Float32} of ones of the given size. (rng is ignored)

source

# WeightInitializers.rand32Function.

rand32(rng::AbstractRNG, size...) = rand(rng, Float32, size...)

Return an Array{Float32} of random numbers from a uniform distribution of the given size.

source

# WeightInitializers.randn32Function.

randn32(rng::AbstractRNG, size...) = randn(rng, Float32, size...)

Return an Array{Float32} of random numbers from a standard normal distribution of the given size.

source

# WeightInitializers.glorot_normalFunction.

glorot_normal(rng::AbstractRNG, size...; gain = 1)

Return an Array{Float32} of the given size containing random numbers drawn from a normal distribution with standard deviation gain * sqrt(2 / (fan_in + fan_out)). This method is described in [1] and also known as Xavier initialization.

References

[1] Glorot, Xavier, and Yoshua Bengio. "Understanding the difficulty of training deep feedforward neural networks." Proceedings of the thirteenth international conference on artificial intelligence and statistics. 2010.

source

# WeightInitializers.glorot_uniformFunction.

glorot_uniform(rng::AbstractRNG, size...; gain = 1)

Return an Array{Float32} of the given size containing random numbers drawn from a uniform distribution on the interval \([-x, x]\), where x = gain * sqrt(6 / (fan_in + fan_out)). This method is described in [1] and also known as Xavier initialization.

References

[1] Glorot, Xavier, and Yoshua Bengio. "Understanding the difficulty of training deep feedforward neural networks." Proceedings of the thirteenth international conference on artificial intelligence and statistics. 2010.

source

# WeightInitializers.kaiming_normalFunction.

kaiming_normal(rng::AbstractRNG, size...; gain = 2f0)

Return an Array{Float32} of the given size containing random numbers taken from a normal distribution standard deviation gain / sqrt(fan_in)

References

[1] He, Kaiming, et al. "Delving deep into rectifiers: Surpassing human-level performance on imagenet classification." Proceedings of the IEEE international conference on computer vision. 2015.

source

# WeightInitializers.kaiming_uniformFunction.

kaiming_uniform(rng::AbstractRNG, size...; gain = 2f0)

Return an Array{Float32} of the given size containing random numbers drawn from a uniform distribution on the interval [-x, x], where x = gain * sqrt(3/fan_in).

References

[1] He, Kaiming, et al. "Delving deep into rectifiers: Surpassing human-level performance on imagenet classification." Proceedings of the IEEE international conference on computer vision. 2015.

source

# WeightInitializers.truncated_normalFunction.

truncated_normal([rng = default_rng_value()], size...; mean = 0, std = 1, lo = -2, hi = 2)

Return an Array{Float32} of the given size where each element is drawn from a truncated normal distribution. The numbers are distributed like filter(x -> lo<=x<=hi, mean .+ std .* randn(100)).

source