亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我應該如何定義這個 CNN 的損失和性能指標?

我應該如何定義這個 CNN 的損失和性能指標?

慕無忌1623718 2022-11-18 18:21:50
我已經為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
查看完整描述

1 回答

?
大話西游666

TA貢獻1817條經驗 獲得超14個贊

對于分類輸出,需要使用softmax。

classification = Dense(units = 43, activation='softmax', name="classification")(d2)

您應該將categorical_crossentropy損失用于分類輸出。

對于回歸,您可以使用mse損失。


查看完整回答
反對 回復 2022-11-18
  • 1 回答
  • 0 關注
  • 135 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號