def _one_hot_(label, num_classes=36):
num_labels = label.shape[0]
index_offset = np.arange(num_labels) * num_classes
labels_one_hot = np.zeros((num_labels, num_classes))
labelNum = []
# ???1???????
for i in label:
# ???
if ord(i) <= 57:
chrvalue = ord(i) - 48
else:
# ???????????????10??????10
chrvalue = ord(str(i).upper()) - 65 + 10
labelNum.append(chrvalue)
newlabel = np.array(labelNum)
labels_one_hot = labels_one_hot.astype(np.float32)
labels_one_hot.flat[index_offset + newlabel.ravel()] = 1.
return labels_one_hot
评论列表
文章目录