我正在嘗試構(gòu)建一個(gè)損失函數(shù),它將計(jì)算兩個(gè)相同大小的期限的均方誤差。換句話(huà)說(shuō),我需要一個(gè)函數(shù)來(lái)計(jì)算矩陣 A 和矩陣 B 上每 2 個(gè)單元格(具有相同行和列)單元格的差異,對(duì)其進(jìn)行平方并計(jì)算差異的平均值。據(jù)我了解 nn.MSELoss 應(yīng)該做到這一點(diǎn)。當(dāng)我將 2 個(gè)張量傳遞給 nn.MSELoss 時(shí),我收到以下錯(cuò)誤消息:RuntimeError: Boolean value of Tensor with more than one value is ambiguous這是我的代碼nn.MSELoss(stack_3[0,:],stack_7[0,:])張量是相同形狀的浮點(diǎn)數(shù)。stack_3.shape, stack_7.shape
(torch.Size([6131, 784]), torch.Size([6131, 784]))
計(jì)算 2 個(gè)張量之間的均方誤差存在困難
江戶(hù)川亂折騰
2023-09-19 17:40:23