我代碼中造成警告的語句是:文章來源:http://www.zghlxwxcb.cn/news/detail-515278.html
value_loss = F.mse_loss(predicted_value, td_value) # predicted_value是預(yù)測(cè)值,td_value是目標(biāo)值,用MSE函數(shù)計(jì)算誤差
原因:mse_loss損失函數(shù)的兩個(gè)輸入Tensor的shape不一致。經(jīng)過reshape或者一些矩陣運(yùn)算以后使得shape一致,不再出現(xiàn)警告了。文章來源地址http://www.zghlxwxcb.cn/news/detail-515278.html
到了這里,關(guān)于【Pytorch警告】Using a target size (torch.Size([])) that is different to the input size (torch.Size([1])的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!