將神經網路模型套用到服飾資料
在這個練習中,你要把前一題建立的全連接神經網路套用到影像資料上。訓練資料提供為兩個變數:train_data 包含 3 種服飾類別、共 50 張影像的像素資料;train_labels 則包含這 50 張影像各自標籤的 one-hot 編碼表示。請先把資料轉換成網路所需的輸入格式,然後使用訓練資料與訓練標籤來擬合模型。
你在前一題已經編譯好的 model,以及 train_data 和 train_labels,都已在你的工作環境中可用。
本練習屬於課程
使用 Keras 進行影像建模
練習說明
- 先將資料重新塑形,以便進行擬合。
- 透過呼叫模型的
.fit()方法,傳入訓練輸入資料與訓練標籤來擬合模型。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Reshape the data to two-dimensional array
train_data = train_data.reshape(____, ____)
# Fit the model
model.fit(____, ____, validation_split=0.2, epochs=3)