第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Keras:基于 Faster-RCNN 預(yù)測(cè)生成目標(biāo)值

Keras:基于 Faster-RCNN 預(yù)測(cè)生成目標(biāo)值

小唯快跑啊 2022-11-09 16:23:11
解決方案好的,我確實(shí)找到了解決方案,也許不是最好的解決方案。本質(zhì)上只是創(chuàng)建了一個(gè)使用TensorFlow的GradientTape的新方法。本質(zhì)上,獲取預(yù)測(cè)、生成目標(biāo)、計(jì)算損失然后更新梯度。with tf.GradientTape() as tape:    # Forward pass    y_preds = self.model(x, training=True)    # Generate the target values from the predictions    actual_deltas, actual_objectness = self.generate_target_values(y_preds, labels)    #Get the loss    loss = self.model.compiled_loss([actual_deltas, actual_objectness], y_preds, regularization_losses=self.model.losses)# Compute gradientstrainable_vars = self.model.trainable_variablesgradients = tape.gradient(loss, trainable_vars)# Update weightsself.model.optimizer.apply_gradients(zip(gradients, trainable_vars))我知道使用 Keras 子類化有更好的方法來(lái)做到這一點(diǎn),但這確實(shí)起到了作用。原帖我目前正在嘗試創(chuàng)建一個(gè)模型,其中需要通過一個(gè)函數(shù)運(yùn)行預(yù)測(cè),該函數(shù)將它們與訓(xùn)練標(biāo)簽進(jìn)行比較。然后此函數(shù)將返回目標(biāo)值。如何訓(xùn)練我的模型,以便將預(yù)測(cè)輸入到我的函數(shù)中并返回函數(shù) pred。我正在使用 Tensorflow 2.1.0 和 Keras 2.2.4-tf編輯:該模型是修改后的 Faster-RCNN 模型。我正在嘗試添加該函數(shù),該函數(shù)接受預(yù)測(cè)(2xN 和 4xN 向量),將它們轉(zhuǎn)換為邊界框,將它們與地面實(shí)況邊界框進(jìn)行比較,然后返回每個(gè)建議的邊界框值應(yīng)該是什么, 為了正確地覆蓋這個(gè)邊界框。
查看完整描述

1 回答

?
莫回?zé)o

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊

好的,我確實(shí)找到了解決方案,也許不是最好的解決方案。本質(zhì)上只是創(chuàng)建了一個(gè)使用 TensorFlow 的 GradientTape 的新方法。本質(zhì)上,獲取預(yù)測(cè)、生成目標(biāo)、計(jì)算損失然后更新梯度。


with tf.GradientTape() as tape:

    # Forward pass

    y_preds = self.model(x, training=True)

    # Generate the target values from the predictions

    actual_deltas, actual_objectness = self.generate_target_values(y_preds, labels)

    #Get the loss

    loss = self.model.compiled_loss([actual_deltas, actual_objectness], y_preds, regularization_losses=self.model.losses)

# Compute gradients

trainable_vars = self.model.trainable_variables

gradients = tape.gradient(loss, trainable_vars)

# Update weights

self.model.optimizer.apply_gradients(zip(gradients, trainable_vars))

我知道使用 Keras 子類化有更好的方法來(lái)做到這一點(diǎn),但這確實(shí)起到了作用。


查看完整回答
反對(duì) 回復(fù) 2022-11-09
  • 1 回答
  • 0 關(guān)注
  • 118 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)