zoukankan      html  css  js  c++  java
  • tensorflow深度学习-mnist数据集读入-初试

     1 import os
     2 os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
     3 import tensorflow as tf
     4 from tensorflow import keras
     5 from  tensorflow.keras import layers
     6 import numpy as np
     7 import matplotlib.pyplot as plt
     8 
     9 # from tensorflow.keras.datasets import mnist
    10 # mnist is the handwriting number dataset 0-9
    11 
    12 def load_mnist(path):
    13     f=np.load(path)
    14     x_train, y_train = f['x_train'], f['y_train']
    15     x_test, y_test = f['x_test'], f['y_test']
    16     f.close()
    17     return (x_train, y_train), (x_test, y_test)
    18 
    19 
    20 (x_train, y_train), (x_test, y_test) = load_mnist("......")
    21 print(x_train.shape)
    22 print(y_train.shape)
    23 
    24 
    25 N=3
    26 idx=0
    27 for pages in range(5):
    28     for i in range(N):
    29         for j in range(N):
    30             num=i*N+j
    31             plt.subplot(N,N,num+1)
    32             plt.imshow(x_train[num+idx],cmap=plt.get_cmap('gray'))
    33     idx+=N*N
    34     # show the plot
    35     plt.show()

    网络还没有搭建,先就读入看看效果

    输出了五张3*3手写数字的图片,还阔以

    ~~Jason_liu O(∩_∩)O
  • 相关阅读:
    2019年6月英语四六级试题及答案和视频教程
    经典解压缩软件 WinRAR 5.90 sc 官方去广告版
    会动的边框
    萌萌达机器人
    背景图片跟随鼠标动
    烟花代码
    常用正则表达式
    计算器
    顶部下啦菜单
    ps用画笔工具设计水墨圆环
  • 原文地址:https://www.cnblogs.com/JasonCow/p/14521589.html
Copyright © 2011-2022 走看看