Documentation
¶
Overview ¶
Package initializers include several weight initializers, to be used with context. They implement computation.VariableInitializer type.
Index ¶
Constants ¶
const NoSeed = int64(0)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type VariableInitializer ¶
VariableInitializer builds a node that returns a value to initialize a variable of the given shape. It is defined in the Context.
func GlorotUniformFn ¶ added in v0.9.0
func GlorotUniformFn(initialSeed int64) VariableInitializer
GlorotUniformFn return a Glorot uniform initializer, also called Xavier uniform initializer.
It can be set to a context with `ctx.WithInitializer(GlorotUniformFn(initialSeed))`, where `initialSeed` can be 0 for a random seed to be generated.
For float and complex values, it draws samples from a uniform distribution within `[-limit, limit]`, where `limit = sqrt(3 / ((fan_in + fan_out)/2))` (`fan_in` is the number of input units in the weight tensor and fan_out is the number of output units).
Since it doesn't have semantic information about the variables being created, it makes some assumptions about the shapes of the variables: it assumes either these are weights for biases, matrix multiplications or 2D or 3D convolutions. Using it for different types of shapes may not get the expected result.
The parameter `initialSeed` is used to initialize the random number generator -- only the first time it is used for a graph. If it is set to 0 (NoSeed), a random seed is instead generated (from the nanosecond clock).
Non-float and non-complex variables are initialized with zero instead.
func RandomNormalFn ¶
func RandomNormalFn(initialSeed int64, stddev float64) VariableInitializer
RandomNormalFn returns an initializer that generates random normal values with the given standard deviation and mean set to 0.
The parameter `initialSeed` is used to initialize the random number generator -- only the first time it is used for a graph. If it is set to 0 (NoSeed), a random seed is instead generated (from the nanosecond clock).
Non-float and non-complex variables are initialized with zero instead.
func RandomUniformFn ¶
func RandomUniformFn(initialSeed int64, min, max float64) VariableInitializer
RandomUniformFn return an initializer that generates a random uniform values from [min, max).
The parameter `initialSeed` is used to initialize the random number generator -- only the first time it is used for a graph. If it is set to 0 (NoSeed), a random seed is instead generated (from the nanosecond clock).
Non-float and non-complex variables are initialized with zero instead.