import numpy as np import matplotlib.pyplot as plt x = np.array([[9], [4], [8], [7]]) #一維陣列建立 x x.shape x = np.array([[9, 4, 8 , 7], [8, 7, 4, 5]]) #二維陣列建立 x x.shape # 矩陣 a = x[0] b = x[1] a a.reshape(2,2) a = a.reshape(2,2) b = b.reshape(2,2) x = np.array([a,b]) x x.shape #one hot encoding from tensorflow.keras.utils import to_categorical x=[0,1,2,3,4,5] # 類別個數:6 x_1 = to_categorical(x,6) x_1