pytorch奇葩錯誤

2021-09-26 13:33:44 字數 582 閱讀 8663

訪問本站**效果更佳

在pytorch中遇到如下錯誤:

libraries/torch/extra/cunn/lib/thcunn/classnllcriterion.cu:52: void 

cunn_classnllcriterion_updateoutput_kernel(dtype *, dtype *, dtype *, long *,

dtype *, int, int, int, int) [with dtype = float, acctype = float]: block:

[0,0,0], thread: [2,0,0] assertiont >= 0 && t < n_classesfailed.

造成這個問題的原因就是在做分類任務時,訓練資料中存在超出分類數目的標籤。比如我一共設定了8個類,但是訓練資料中的標籤裡出現了9,就會報這個錯誤。

那麼問題來了,這裡有乙個陷阱。

訓練資料中的標籤含0也會報上述錯誤。這個就非常詭異了。一般我們都從0開始數,但是在pytorch裡0以下的類別標籤都是要報錯的。所以如果類別標籤從0開始,要給所有類別標籤都加上一。

奇葩Oracle錯誤

一句話 create table es product id number 10,0 primary key not null,商品id sort id number 10,0 not null,商品類別id name varchar2 40 not null,商品名稱 price number 1...

Pytorch 各種奇葩古怪的使用方法

不間斷更新。增加layer很方便,可以使用model.add module layer name layer 刪減layer很少用的到,之所以我會有這麼乙個需求,是因為我需要使用vgg做遷移學習,而且需要修改最後的輸出。而vgg由兩個部分組成 features和classifier,這兩個部分都是t...

python json 各種奇葩錯誤解決示例

encoding utf 8 python2.7 re正規表示式 import re import json with open 74508.txt r as fr 需要先將文字分行,最初的文字未分行。c fr.readline with open 74508.txt r as fr c fr.re...