import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np
import sklearn
import pandas as pd
import os
import sys
import time
import tensorflow as tf
from tensorflow import keras
print(tf.__version__)
print(sys.version_info)
for module in mpl, np, sklearn, tf, keras:
print(module.__name__, module.__version__)
fashion_mnist = keras.datasets.fashion_mnist
(x_train_all, y_train_all), (x_test, y_test) = fashion_mnist.load_data()
x_valid, x_train = x_train_all[:5000], x_train_all[5000:]
y_valid, y_train = y_train_all[:5000], y_train_all[5000:]
print(x_valid.shape, y_valid.shape)
print(x_train.shape, y_train.shape)
print(x_test.shape, y_test.shape)
#单张图像数据显示
def show_single_image(img_arr):
plt.imshow(img_arr, cmap="binary")
plt.show()
show_single_image(x_train[9])
#多张图片显示
dsample = []
for (root, dirs, files) in os.walk("F:/照片/图片/搜狗壁纸/图片/WallPapers"):
for i in range(len(files)):
pic = root+'/'+files[i]
sample.append(pic)
plt.subplot(221)
a=plt.imread(sample[0])
plt.imshow(a)
plt.subplot(222)
b=plt.imread(sample[1])
plt.imshow(b)
plt.subplot(223)
c=plt.imread(sample[2])
plt.imshow(c)
plt.subplot(224)
d=plt.imread(sample[3])
plt.imshow(d)
plt.show()
图片显示
最新推荐文章于 2023-11-27 09:36:29 发布