25-Mnist02

from tensorflow.examples.tutorials.mnist.input_data import read_data_sets
import numpy as np
import cv2
import tensorflow as tf


class Config:
    def __init__(self):
        self.sample_path = '../deeplearning_ai12/p07_mnist/MNIST_data'


class Tensors:
    def __init__(self, config):
        x = tf.placeholder(tf.float32, [], 'x')


class Samples:
    def __init__(self, config):
        ds = read_data_sets(config.sample_path)
        print(ds.train.num_examples)
        print(ds.validation.num_examples)
        print(ds.test.num_examples)

        xs, ys = ds.train.next_batch(200)
        # xs: [200, 784]
        # ys: [200]

        print(ys)
        xs = np.reshape(xs, [-1, 28, 28])
        xs = np.transpose(xs, [1, 0, 2])  # [28, -1, 28]
        xs = np.reshape(xs, [28, -1, 28 * 20])  # [28, -1, 560],
        xs = np.transpose(xs, [1, 0, 2])  # [-1, 28, 560]
        xs = np.reshape(xs, [-1, 28 * 20])

        cv2.imshow('My digits', xs)
        cv2.waitKey()


class App:
    def __init__(self, config):
        self.samples = Samples(config)
        self.tensors = Tensors(config)

    def train(self):
        pass


if __name__ == '__main__':
    config = Config()
    app = App(config)

    app.train()

D:\Anaconda\python.exe D:/AI20/HJZ/05-深度学习项目/deeplearning_20/p25_mnist/mnist02.py
WARNING:tensorflow:From D:/AI20/HJZ/05-深度学习项目/deeplearning_20/p25_mnist/mnist02.py:19: read_data_sets (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
WARNING:tensorflow:From D:\Anaconda\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py:260: maybe_download (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Please write your own downloading logic.
WARNING:tensorflow:From D:\Anaconda\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py:262: extract_images (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting ../deeplearning_ai12/p07_mnist/MNIST_data\train-images-idx3-ubyte.gz
Extracting ../deeplearning_ai12/p07_mnist/MNIST_data\train-labels-idx1-ubyte.gz
Extracting ../deeplearning_ai12/p07_mnist/MNIST_data\t10k-images-idx3-ubyte.gz
WARNING:tensorflow:From D:\Anaconda\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py:267: extract_labels (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting ../deeplearning_ai12/p07_mnist/MNIST_data\t10k-labels-idx1-ubyte.gz
WARNING:tensorflow:From D:\Anaconda\lib\site-packages\tensorflow\contrib\learn\python\learn\datasets\mnist.py:290: DataSet.__init__ (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
55000
5000
10000
[7 2 3 7 6 0 7 8 7 6 1 3 7 9 6 2 1 9 1 2 1 0 0 5 2 3 6 6 5 8 8 3 6 8 2 3 7
 6 3 9 1 0 4 7 5 7 9 3 7 2 1 9 2 4 6 2 5 7 8 0 1 6 9 2 1 5 1 8 7 7 9 3 0 3
 6 2 1 2 9 1 5 4 7 1 8 9 6 3 6 0 1 1 6 9 5 0 3 2 2 4 9 5 0 3 7 9 9 4 4 8 1
 6 8 0 2 0 4 5 3 2 3 7 5 4 0 9 0 7 0 1 3 1 9 7 0 7 5 4 5 3 3 1 0 3 6 1 0 6
 1 4 9 2 6 7 3 0 2 8 4 8 1 2 2 9 2 9 3 9 1 4 4 2 6 1 0 1 2 1 9 7 3 5 0 5 2
 8 2 4 4 2 0 2 8 2 4 5 9 5 8 3]

在这里插入图片描述

发布了125 篇原创文章 · 获赞 2 · 访问量 2616

猜你喜欢

转载自blog.csdn.net/HJZ11/article/details/104790008