chainer.initializers.generate_array

chainer.initializers.generate_array(initializer: chainer.types.AbstractInitializer, shape: Union[int, Sequence[int]], xp: Any, dtype: Optional[Any] = None, device: Optional[Union[backend.Device, chainerx.Device, cuda.Device, str, Tuple[str, int], ModuleType, Tuple[ModuleType, int]]] = None) Union[numpy.ndarray, cuda.ndarray, chainerx.ndarray][source]

Return initialized array.

The algorithms used to make the new values depend on the concrete derived classes. If the initializer has the dtype attribute, it is used to construct the array. Otherwise, chainer.config.dtype is used instead. See Configuring Chainer for the dtype config.

Parameters
  • initializer – A callable object that takes N-dimensional array and edits its value.

  • shape (int or tuple of int) – Shape of the initialized array.

  • xp (module) – cupy, numpy, or chainerx.

  • dtype – Dtype specifier. If omitted, initializer.dtype is used.

  • device – Target device specifier. If omitted, the current device is used for cupy, and the default device is used for chainerx.

Returns

An initialized array.

Return type

N-dimensional array