MATLAB实现one-hot

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhangshengdong1/article/details/89332863

MATLAB实现one-hot

我们以x=[2,2,3]为例

I=eye(max(x))
x_one_hot=I(x,:)

运行后输出

x_one_hot =

     0     1     0
     0     1     0
     0     0     1

就是我们要的one-hot编码

猜你喜欢

转载自blog.csdn.net/zhangshengdong1/article/details/89332863