PyTorch torch.zeros_like function
PyTorch torch reference manual
torch.zeros_like A function in PyTorch for creating an all-zero tensor with the same shape as the input tensor.
Function definition
torch.zeros_like(input, dtype=None, device=None, requires_grad=False)
Usage examples
Example
import
torch
x
=
torch.
randn
(
3
,
4
)
y
=
torch.
zeros_like
(
x
)
(
"x shape:"
,
x.
shape
)
(
"y shape:"
,
y.
shape
)
(
y
)