我已經為GTSRB數據集問題實現了一個帶有兩個輸出層的 CNN 。一個輸出層將圖像分類為各自的類別,第二層預測邊界框坐標。在數據集中,為訓練圖像提供了左上和右下坐標。我們必須對測試圖像進行相同的預測。我如何為回歸層定義損失指標(MSE 或任何其他)和性能指標(R 平方或任何其他),因為它輸出 4 個值(左上點和右下點的 x 和 y 坐標)?下面是模型的代碼。def get_model() : #Input layer input_layer = Input(shape=(IMG_HEIGHT, IMG_WIDTH, N_CHANNELS, ), name="input_layer", dtype='float32') #Convolution, maxpool and dropout layers conv_1 = Conv2D(filters=8, kernel_size=(3,3), activation=relu, kernel_initializer=he_normal(seed=54), bias_initializer=zeros(), name="first_convolutional_layer") (input_layer) maxpool_1 = MaxPool2D(pool_size=(2,2), name = "first_maxpool_layer")(conv_1) #Fully connected layers flat = Flatten(name="flatten_layer")(maxpool_1) d1 = Dense(units=64, activation=relu, kernel_initializer=he_normal(seed=45), bias_initializer=zeros(), name="first_dense_layer", kernel_regularizer = l2(0.001))(flat) d2 = Dense(units=32, activation=relu, kernel_initializer=he_normal(seed=47), bias_initializer=zeros(), name="second_dense_layer", kernel_regularizer = l2(0.001))(d1) classification = Dense(units = 43, activation=None, name="classification")(d2) regression = Dense(units = 4, activation = 'linear', name = "regression")(d2) #Model model = Model(inputs = input_layer, outputs = [classification, regression]) model.summary() return model
我應該如何定義這個 CNN 的損失和性能指標?
慕無忌1623718
2022-11-18 18:21:50