vis4d.op.layer.weight_init

Model weight initialization.

Functions

bias_init_with_prob(prior_prob)

Initialize conv/fc bias value according to a given probability value.

constant_init(module, val[, bias])

Initialize module with constant value.

kaiming_init(module[, negative_slope, mode, ...])

Initialize module with Kaiming initialization.

normal_init(module[, mean, std, bias])

Initialize module with normal distribution.

uniform_init(module[, lower, upper, bias])

Initialize module with uniform distribution.

xavier_init(module[, gain, bias, distribution])

Initialize module with Xavier initialization.

bias_init_with_prob(prior_prob)[source]

Initialize conv/fc bias value according to a given probability value.

Return type:

float

constant_init(module, val, bias=0.0)[source]

Initialize module with constant value.

Return type:

None

kaiming_init(module, negative_slope=0.0, mode='fan_out', nonlinearity='relu', bias=0.0, distribution='normal')[source]

Initialize module with Kaiming initialization.

Parameters:
  • module (nn.Module) – Module to initialize.

  • negative_slope (float, optional) – The negative slope of the rectifier used after this layer (only used with 'leaky_relu'). Defaults to 0.0.

  • mode (str, optional) – Either 'fan_in' (default) or 'fan_out'. Choosing 'fan_in' preserves the magnitude of the variance of the weights in the forward pass. Choosing 'fan_out' preserves magnitudes in the backwards pass. Defaults to “fan_out”.

  • nonlinearity (str, optional) – The non-linear function (nn.functional name). Defaults to “relu”.

  • bias (float, optional) – The bias to use. Defaults to 0.0.

  • distribution (str, optional) – Either 'uniform' or 'normal'. Defaults to “normal”.

Return type:

None

normal_init(module, mean=0.0, std=1.0, bias=0)[source]

Initialize module with normal distribution.

Return type:

None

uniform_init(module, lower=0.0, upper=1.0, bias=0.0)[source]

Initialize module with uniform distribution.

Return type:

None

xavier_init(module, gain=1.0, bias=0.0, distribution='normal')[source]

Initialize module with Xavier initialization.

Return type:

None