因各种原因,国内打开数据集比较慢,需要手动下载
首先打开
https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gzhttps://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
然后需要更改名字
把cifar-10-python.tar的文件名改为cifar-10-batches-py.tar.gz,我的环境这个可以,网上说有的需要改成cifar-10-batches-py.tar才能成功,这个自己尝试下
然后打开C:\Users\用户名\.keras\datasets文件夹。拷贝进去就可以使用了
import tensorflow as tf
import os
import numpy as np
from matplotlib import pyplot as plt
from tensorflow.keras.layers import Conv2D, BatchNormalization, Activation, MaxPool2D, Dropout, Flatten, Dense
from tensorflow.keras import Model
np.set_printoptions(threshold=np.inf)
cifar10 = tf.keras.datasets.cifar10
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0