full

full(tensor: Tensor, value: bool | int | float | complex, *, shape: Sequence[int] | Size | None = None, dtype: dtype | None = None, layout: layout | None = None, device: device | None = None, requires_grad: bool | None = None) Tensor[source]

Returns a tensor based on input filled with specified value.

Parameters:
  • tensor (torch.Tensor) – determines default output properties.

  • value (bool | int | float | complex) – value with to fill the output.

  • shape (Sequence[int] | torch.Size | None, optional) – overrides shape from tensor if specified. Defaults to None.

  • dtype (torch.dtype | None, optional) – overrides data type from tensor if specified. Defaults to None.

  • layout (torch.layout | None, optional) – overrides layout from tensor if specified. Defaults to None.

  • device (torch.device | None, optional) – overrides device from tensor if specified. Defaults to None.

  • requires_grad (bool | None, optional) – overrides gradient requirement from tensor if specified. Defaults to None.

Returns:

tensor like tensor, modified by parameters, filled with value.

Return type:

torch.Tensor

Note

To construct a scalar, set shape to ().