ICNR

class lib.model.initializers.ICNR(initializer: dict[str, Any] | Initializer, scale: int = 2)

Bases: Initializer

ICNR initializer for checkerboard artifact free sub pixel convolution

Parameters:
  • initializer (dict[str, T.Any] | initializers.Initializer) – The initializer used for sub kernels (orthogonal, glorot uniform, etc.)

  • scale (int) – scaling factor of sub pixel convolution (up sampling from 8x8 to 16x16 is scale 2). Default: 2

Return type:

The modified kernel weights

Example

>>> x = conv2d(... weights_initializer=ICNR(initializer=he_uniform(), scale=2))

References

Andrew Aitken et al. Checkerboard artifact free sub-pixel convolution https://arxiv.org/pdf/1707.02937.pdf, https://distill.pub/2016/deconv-checkerboard/ https://gist.github.com/A03ki/2305398458cb8e2155e8e81333f0a965

Methods Summary

__call__(shape[, dtype])

Returns a tensor object initialized as specified by the initializer.

clone()

from_config(config)

Instantiates an initializer from a configuration dictionary.

get_config()

Return the ICNR Initializer configuration.

Methods Documentation

__call__(shape: list[int] | tuple[int, ...], dtype: str | None = 'float32') Tensor

Returns a tensor object initialized as specified by the initializer.

Parameters:
  • shape (list[int] | tuple[int, ...]) – Shape of the tensor.

  • dtype (str | None) – Optional dtype of the tensor.

Return type:

Tensor

clone()
classmethod from_config(config)

Instantiates an initializer from a configuration dictionary.

Example:

`python initializer = RandomUniform(-1, 1) config = initializer.get_config() initializer = RandomUniform.from_config(config) `

Parameters:

config – A Python dictionary, the output of get_config().

Returns:

An Initializer instance.

get_config() dict[str, Any]

Return the ICNR Initializer configuration.

Return type:

The configuration for ICNR Initialization

__call__(shape: list[int] | tuple[int, ...], dtype: str | None = 'float32') Tensor

Returns a tensor object initialized as specified by the initializer.

Parameters:
  • shape (list[int] | tuple[int, ...]) – Shape of the tensor.

  • dtype (str | None) – Optional dtype of the tensor.

Return type:

Tensor

get_config() dict[str, Any]

Return the ICNR Initializer configuration.

Return type:

The configuration for ICNR Initialization