iPAS 考題解析考慮使用 CIFAR-10 資料集進行資料處理,資料包括 32×32 像素的多筆彩色照片。下列程式碼的資料處理,請選出正確的選項。 ```python from tensorflow.keras import datasets, utils import pandas as pd (x_train, y_train), (x_test, y_test) = datasets.cifar10.load_data() # type(x_train) -> numpy.ndarray # x_train.shape, y_train.shape, x_test.shape, y_test.shape # -> (50000, 32, 32, 3) (50000, 1) (10000, 32, 32, 3) (10000, 1) # x_train.min() -> 0 # x_train.max() -> 255 ```
你的作答
在題目頁作答不會存進學習紀錄,想留下紀錄可以到題庫練習。
解析
正確答案:B. 測試集(x_test)資料集個數為 10000 筆
由程式碼輸出可知:x_train.shape = (50000, 32, 32, 3),訓練集有 50000 筆;x_test.shape = (10000, 32, 32, 3),測試集有 10000 筆(B 正確)。type(x_train) = numpy.ndarray,不是 Pandas DataFrame(C 錯誤)。像素值歸一化應用 float32 而非 int32:x_train = x_train.astype('float32') / 255.0(D 錯誤)。
每個選項為什麼對或錯
-
A 訓練集(x_train)資料集個數為 100000 筆 錯誤選項
訓練集有 50000 筆,非 100000 筆。
-
B 測試集(x_test)資料集個數為 10000 筆 正解
測試集 x_test.shape = (10000, ...),確實有 10000 筆,此為正確答案。
-
C 訓練集(x_train)是 Pandas 資料框(DataFrame)物件 錯誤選項
type(x_train) = numpy.ndarray,不是 Pandas DataFrame。
-
D 如果希望將訓練集(x_train)像素值轉換為[0, 1]的範圍,則可以輸入:x_train = x_train.astype('int32') / 255.0 錯誤選項
應使用 float32 進行除法,int32 / 255 會截斷為整數(0 或 1),結果不正確。
答案、題目或解析有問題?回報這題