独热码 Share 独热编码 tf.one_hot(待转换数据,depth=及分类) 1234classes = 3labels = tf.constant([1,0,2]) # 输入元素最小为0,最大为2output=tf.one_hot(labels,depth=classes)ptint(output()) 独热码转符合概率分布 公式: Softmax(yi)=eyiΣj=0neyi\mathrm{Softmax}(y_i)=\frac{\mathrm{e}^{y_i}}{\Sigma_{j=0}^n\mathrm{e}^{y_i}} Softmax(yi)=Σj=0neyieyi