美文网首页
2020-10-02

2020-10-02

作者: HelloSam | 来源:发表于2020-10-02 09:46 被阅读0次
    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

    相关文章

      网友评论

          本文标题:2020-10-02

          本文链接:https://www.haomeiwen.com/subject/prkbuktx.html