#导入数据 import tensorflow as tf from tensorflow.keras import datasets,layers,models import matplotlib.pyplot as plt (train_images,train_labels),\ (test_images,test_labels) = datasets.cifar10.load_data() #归一化 #将像素的值标准化至0至1的区间内 train_images,test_images = train_images/255.0,test_images/255.0 train_images.shape,test_images.shape,train_labels.shape,test_labels.shape ((50000, 32, 32, 3), (10000, 32, 32, 3), (50000, 1), (10000, 1)) #可视化 class_names = ['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck'] plt.figure(figsize=(20,10)) for i in range(20): plt.subplot(5,10,i+1