フリー問題

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

問題文

A developer needs the mean of a tensor of shape (8, 100) along the feature axis, and wants the result to keep a trailing dimension of size 1 so that it can be subtracted from the original tensor without reshaping. Which call does that?

選択肢

  1. x.mean(dim=1, keepdim=True), which reduces the second axis but leaves it in place with size 1.
  2. x.mean(1).reshape(8, 100), which restores the shape.
  3. x.mean(dim=1), because the reduction functions preserve the reduced axis with size 1 by default and only drop it when asked to.
  4. x.mean(axis=1, squeeze=False), which keeps the reduced axis.

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

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