zoukankan      html  css  js  c++  java
  • 学习进度笔记09

    今天通过观看老师分享的视频教程,学习了mnist的使用方法以及对数据集的操作:

    代码如下:

    import tensorflow as tf
    import numpy as np
    import matplotlib.pyplot as plt
    from tensorflow.examples.tutorials.mnist import input_data

    mnist = input_data.read_data_sets('data/',one_hot=True)
    #print
    trainimg = mnist.train.images
    trainlabel = mnist.train.labels
    testimg = mnist.test.images
    testlabel = mnist.test.labels
    print("trainlabel:",type(trainlabel),"shape:",trainlabel.shape)
    print("trainimg:",type(trainimg),"shape:",trainimg.shape)
    print("testlabel:",type(testlabel),"shape:",testlabel.shape)
    print("testimg:",type(testimg),"shape:",testimg.shape)

    nsample = 5
    randidx = np.random.randint(trainimg.shape[0],size=nsample)
    for i in randidx:
    cur_img = np.reshape(trainimg[i,:],(28,28))
    cur_label = np.argmax(trainlabel[i,:])
    plt.matshow(cur_img,cmap=plt.get_cmap('gray'))
    plt.title("" + str(i) + "th Training Data " + "Label is " + str(cur_label))
    print("" + str(i) + "th Training Data " + "Label is " + str(cur_label))
    plt.show()

    batch_size = 100
    batch_xs,batch_ys = mnist.train.next_batch(batch_size)
    print("batch_xs:",type(batch_xs),"shape:",batch_xs.shape)
    print("batch_ys:",type(batch_ys),"shape:",batch_ys.shape)
    输出结果截图:
     

     

     

     

     



  • 相关阅读:
    20190817-T1-LOJ6322「雅礼国庆 2017 Day6」Star Way To Heaven
    20190817-涪
    20190816-周期
    考试总结 模拟95
    考试总结 模拟94
    考试总结 模拟93
    考试总结 模拟92
    考试总结 模拟91
    考试总结 模拟90
    考试总结 模拟89
  • 原文地址:https://www.cnblogs.com/lijiawei1-2-3/p/14273791.html
Copyright © 2011-2022 走看看