2020-10-02
2020-10-02 本文已影响0人
HelloSam
import tensorflow as tf
import numpy as np
# 生成测试集的标签,佯装是一个mnist手写数据集的标签(10分类)(生成5个数据)
y_test = np.random.randint(1,10,size=5).tolist()
print(y_test)
y_test = tf.keras.utils.to_categorical(y_test,num_classes=10)
print(y_test)
输出结果为:
![](https://img.haomeiwen.com/i15614866/46418b4672cfe6e9.png)