scalar¶
- scalar(value: bool | int | float | complex, tensor: Tensor, *, dtype: dtype | None = None, layout: layout | None = None, device: device | None = None, requires_grad: bool | None = None) Tensor[source]¶
Returns a scalar tensor based on input with specified value.
Shortcut for
full()withshape=().- Parameters:
value (bool | int | float | complex) – value with to fill the output.
tensor (torch.Tensor) – determines default output properties.
dtype (torch.dtype | None, optional) – overrides data type from
tensorif specified. Defaults toNone.layout (torch.layout | None, optional) – overrides layout from
tensorif specified. Defaults toNone.device (torch.device | None, optional) – overrides device from
tensorif specified. Defaults toNone.requires_grad (bool | None, optional) – overrides gradient requirement from
tensorif specified. Defaults toNone.
- Returns:
scalar tensor like
tensor, modified by parameters, filled withvalue.- Return type: