分类网络中为图像类别打标签

#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

猜你喜欢

转载自blog.csdn.net/weixin_41855385/article/details/84449569