本实例采用的是mnist数据集, 我的数据集已经是解压好的图片,需要mnist数据集的请在评论区留言,看到第一时间回复, 谢谢。
接下来我们来看看具体的过程, 废话不多, 上代码:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @ProjectName : 02_load_mnist.py
# @DateTime : 2019-11-23 10:21
# @Author : 皮皮虾
import os
import argparse
import logging
import numpy as np
import tensorflow as tf
from sklearn.utils import shuffle
from matplotlib import pyplot as plt
def load_mnist_data(src_path):
images_path_list = []
labels_list = []
sub_dir = os.listdir(path=src_path)
for _dir_ in sub_dir:
image_dirname_path = os.path.join(src_path, _dir_)
images_list = os.listdir(image_dirname_path)
for image in images_list:
image_path = os.path.join(image_dirname_path, image)
# get each image path
images_path_list.append(image_path)
# get each image labe