AI & Machine Learning クイズ: NumPy Broadcasting & Vectorization

Broadcasting lets NumPy combine arrays of different shapes without loops, and it is behind most feature scaling and distance code in machine learning. This quiz tests the broadcasting rules, the shapes they produce and the errors you get when shapes do not line up.

ふつう 10問 約6分 合格ライン 80%

モードを選ぶ

ゲストとしてプレイ中です。ログインすると XP と連続記録が保存されます。

例題

第1問 / 全10問

What does this print?

import numpy as np
a = np.array([[1, 2, 3], [4, 5, 6]])
b = np.array([10, 20, 30])
print((a + b).tolist())
答えを見る

A. [[11, 22, 33], [14, 25, 36]] b has shape (3,), which matches the last dimension of a (2, 3), so it is added to every row. Adding a different number to each row would need a column of shape (2, 1).

このクイズの内容

  • The broadcasting rule, compared from the trailing dimension
  • Row vectors, column vectors and the shapes they make
  • Centering data with X - X.mean(axis=0)
  • np.where() instead of an if inside a loop
  • Why in-place operations can fail on integer arrays

よくある質問

アカウントは必要ですか?

いいえ、誰でも遊べます。ログインすると XP、連続記録、バッジ、履歴が保存されます。

何度でも挑戦できますか?

はい。ベストスコアが記録され、問題と選択肢は毎回シャッフルされます。