フリー問題

PyTorch Certified Associate のフリー問題 8 / 20 問目

問題文

A developer needs a new tensor of zeros with the same shape, dtype, and device as an existing tensor x. Which call expresses that most directly?

選択肢

  1. torch.zeros(x.shape), which is documented to inherit the dtype and the device of the tensor whose shape was passed in as the argument.
  2. x.fill_(0), which produces a new tensor of zeros with the same shape and dtype.
  3. x.zero(), so the zero tensor is built from the shape of x and nothing else.
  4. torch.zeros_like(x), which copies the shape, dtype, and device of x.

解答・解説を確認するには

正解と解説の確認、回答の記録には無料登録が必要です。登録すると演習モードでフリー問題に回答し、正誤と解説をその場で確認できます。