フリー問題

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

問題文

A developer writes tensor_on_gpu.numpy() to inspect values and gets an error. What is the correct way to obtain a NumPy array from a tensor that lives on an accelerator?

選択肢

  1. Move it to the CPU first, then convert, for example with tensor_on_gpu.cpu().numpy().
  2. Convert the array afterwards with numpy.asarray on the result, so the values are pulled across and copied.
  3. Use the tolist method, which works on any device.
  4. Pass the target device to the conversion, because the conversion method accepts a device argument that performs the transfer and the conversion in a single step for convenience.

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

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