1. 程式人生 > >分類網路中為影象類別打標籤

分類網路中為影象類別打標籤

#labels=[‘cube’,‘fourpyramid’,‘quadrangular’,‘tripyramid’]
#labels字串長為400

from sklearn.preprocessing import LabelBinarizer

lb = LabelBinarizer()
lb.fit(labels)
labels_vecs = lb.transform(labels)
print(lb.transform(labels))

標籤為[[1 0 0 0]
[1 0 0 0]

[0 1 0 0]
[0 1 0 0]

[0 0 1 0]
[0 0 1 0]

[0 0 0 1]
[0 0 0 1]]
參考文件:

https://blog.csdn.net/gao1440156051/article/details/55096630
https://www.jianshu.com/p/88c4ae92dc2e