TensorFlow实现one-hot编码TensorFlow2入门手册

Posted K同学啊

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TensorFlow实现one-hot编码TensorFlow2入门手册相关的知识,希望对你有一定的参考价值。


代码实现:

from tensorflow.keras.utils import to_categorical
onehotencoder = OneHotEncoder()
a = to_categorical(val_label)
b = to_categorical(val_pre)
a

效果图:

以上是关于TensorFlow实现one-hot编码TensorFlow2入门手册的主要内容,如果未能解决你的问题,请参考以下文章