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)
输出结果为:
image.png
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)
输出结果为:
本文标题:2020-10-02
本文链接:https://www.haomeiwen.com/subject/prkbuktx.html
网友评论